Reputation: 2615
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 selectable similar to the Ag.vim plugin?
Files containing the search term will be listed in the split window, along with the line number of the occurrence, once for each occurrence. [Enter] on a line in this window will open the file, and place the cursor on the matching line.
Upvotes: 3
Views: 97
Reputation: 45087
:vimgrep/pattern/g %
Or maybe something like this:
nnoremap <leader>/ :vimgrep/<c-r>//g %<cr>:copen<cr>
Vimcast did a nice episode on this topic: Search multiple files with :vimgrep
For more help see:
:h :vimgrep
:h :caddexpr
Upvotes: 3