Hi inthewild!
On Do, 04 Jun 2009, [email protected] wrote:
> does anybody know how to get the number of search results inside a
> file?
> Something like " NUMBER_OF_CURENT_RESULT ::
> NUMBER_OF_TOTAL_OCCURRENCES" on statusline would be perfectly.
I am not sure, I understand the difference between
Number_of_current_result vs. Number_of_total_occurrences. But here is
my proposal:
func! CountSearch()
let cs=getpos('.')
redir => search
silent :%s//&/nge
redir END
call setpos('.', cs)
if search != ''
let s=split(substitute(search, '\n', '', ''), ' ')
let search=s[0] . '/' . s[3]
else
let search='0/0'
endif
return @/ . ': ' . search
endfunc
func! MyStl()
let stl='...' " set you'r usual Statusline settings here
let sc=CountSearch()
return stl.sc
endfunc
set stl=%!MyStl()
regards,
Christian
--
:wq!
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---