I'm reading through a large C++ code base in Vim.
Within a single file, I can do
/foo
n
n
n
Now, if I want to search through more than one file, I have to do:
:vimgrep /foo/
:cn
:cn
:cn
Now, typing :cn
is so much less convenient than n
. Is there a way to search through vimgrep results with n
(like searches with /
) instead of :cn
?
Use the Quickfix List
. It will automatically be filled with found matches (no matter if you use :grep
or :vimgrep
). It can be navigated with the usual keys (so the key for "next" is j
instead of n
).
To open it use :copen
.
This is what I have in my .vimrc exactly for this purpose:
nmap <F7> :cp^M
nmap <F8> :cn^M
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With