There is a nice feature in Google Chrome when you do a search. It tells you the number of matches there is for the keyword you are searching for. However, in Vim I don\'t se
another nice vim plugin for that: https://github.com/google/vim-searchindex
will be shown like this:
A alternative is to count using the grep
command.
Ex. If you want to search TODO
in current file is:
:echo system('grep -c TODO ' . expand('%:p'))
I'm not sure exactly what version added it, but this is built into Vim now, you just need to:
:set shortmess-=S
Added sometime in the 8.1.x patches (as of this writing we're at 8.1.2300).
:vim[grep][!] /{pattern}/[g][j] {file} ...
Vimgrep uses Vim's built-in regex search engine, so you can reuse the patterns from Vim's standard search command. So, I first test the search pattern the normal way using: /{pattern}/
Then enter the following:
:vim /CTRL+r//g %
where CTRL+r/
will insert the last search pattern after the first slash. The status line will display (1 of max), where max is the maximum number of matches for the {pattern}
. Then use the :cnext
and :cprev
to search for the next & previous matches and :cfirst
and :clast
for the first and last matches. These 4 commands can be remapped to make them faster to execute.
Plugin index search. Newest version here.
There is a new feature
:set shortmess-=S
Added sometime in the 8.1.x patches (as of this writing we're at 8.1.2300). mentioned bellow by @ben - On neovim this is default.