Selectable list of occurrences of the searched word in the current file.

You can use the following to get a list of matches in a file.

:g/<MATCH_THIS>/p

Is there a way to make this list more like the Ag.vim plugin ?

Files containing the search query will be indicated in a split window along with the entry line number once for each event. [Enter] in a line in this window will open the file and place the cursor in the corresponding line.

+3
source share
1 answer
:vimgrep/pattern/g %

Or maybe something like this:

nnoremap <leader>/ :vimgrep/<c-r>//g %<cr>:copen<cr>

Vimcast made a good episode on this topic: Finding multiple files with: vimgrep

For more help see:

:h :vimgrep
:h :caddexpr
+3
source

All Articles