Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a shorter key combination than :cn to go to the next item in the quickfix list?

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?

like image 434
anon Avatar asked Feb 06 '10 11:02

anon


2 Answers

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.

like image 50
Benjamin Bannier Avatar answered Jan 03 '23 05:01

Benjamin Bannier


This is what I have in my .vimrc exactly for this purpose:

nmap <F7> :cp^M
nmap <F8> :cn^M
like image 25
Michael Krelin - hacker Avatar answered Jan 03 '23 04:01

Michael Krelin - hacker