How to jump between templates when using: vimgrep (Quickfix list)?

I am new to vim and still learning some of its features. I have a problem with vimgrep. I can find a template like this vimgrep /define/ ** to find and open the next file containing define . But I still could not find out how to go to the next file / line that matches my pattern. Any pointers?

+45
vim
Oct 24 '11 at 18:52
source share
2 answers

Useful commands for the quickfix list (brackets around the omitted part of the commands):

  • :cn[ext] and :cp[revious] go to the next and previous record
  • :cnf[ile] and :cpf[ile] go to the next and previous file (if the quickfix list is not sorted by file, you can write a function that getqflist() performs sorting and then setqflist()
  • :cr[ewind] and :cla[st] go to the beginning or end of the quick delete list
  • :col[der] and :cnew[er] will go through the historical quick fix lists.

Needless to say, there are many other commands, and you can find them in :help quickfix .

Personally, I have the following cards:

  | ΓΈ | SHIFT | CTRL ------+--------+---------+--------- <F11> | :cprev | :cpfile | :colder <F12> | :cnext | :cnfile | :cnewer 

Of course, if you use the list of locations instead of the quickfix ( :lvimgrep ) list, then the same commands exist, just replace the initial c with l and it.

Vim 8 Add-ons :

  • :cdo : run the command for all entries in the quick delete list. For example :vim /foo/ *.cpp *.h *.hpp may follow :cdo s/pattern/replacement/g
  • :cfdo : run the command all files in quickfix list. For example, photos :vim /foo/ *.cpp *.h *.hpp may follow :cfdo %s/2ndpattern/2ndreplacement/g
+69
Oct 24 '11 at 19:15
source share

To move on to the next patter appearance, you can use :cnext . You can go backwards with :cnext .

I'm not sure if I can skip all occurrences to the next file automatically, but you can open the quickfix window with :cwindow to view a list of matches and go to these matches by pressing Enter on the entry in the list.

+7
Oct 24 2018-11-11T00:
source share



All Articles