4

I just found out how to use vimgrep command to search for a particular string in multiple files. I know that the search results are stored in quickfix

I use :cnext to go to the next matching pattern. But this is not a feasible option if there are hundreds of search results.

Can someone please explain how to use quickfix?

DmitryK
  • 5,542
  • 1
  • 22
  • 32
Sagar Jain
  • 7,475
  • 12
  • 47
  • 83

2 Answers2

7

The quickfix list is a list of entries containing position, file, and message. It often used for searches like :vimgrep and :grep as well as finding errors via :make.

Here are a few quickfix list commands to get you up and running fast:

  • Use :cnext and :cprev to move between your errors/matches.
  • :cfirst and :clast to go to the first and last error/matches respectively.
  • :copen to open up the quickfix list in a window (:cclose to close)
  • :cwindow to open quickfix list window only if there are errors
  • :cc to display the current error/match.
  • May want to use better mappings for :cnext and friends. I suggest Tim Pope's unimpaired plugin

For more help see the following:

:h quickfix
:h :cnext
:h :cfirst
:h :cope
:h :cwindow
:h :cc
Peter Rincker
  • 43,539
  • 9
  • 74
  • 101
-1

If one reads through :help quickfix, the answer to all your questions becomes readily apparent.

For a specific section of the help doc, try :help quickfix-window.

To open a quickfix window, which will show all the results, run the command

:copen

Which, can be shortened to

:cope
DoYouEvenCodeBro
  • 391
  • 3
  • 14