vimtricks.wiki Concise Vim tricks, one at a time.

How do I navigate through the quickfix list?

Answer

:cnext and :cprev

Explanation

The quickfix list holds a set of file positions, typically from compiler errors, grep results, or other tools. You navigate it with :cnext and :cprev to step through each entry.

How it works

  • :cnext (or :cn) moves to the next quickfix entry
  • :cprev (or :cp) moves to the previous entry
  • :cfirst and :clast jump to the first and last entries
  • :copen opens the quickfix window

Example

After running :make and getting 5 errors:

:cnext    " Jump to error 2
:cnext    " Jump to error 3
:cprev    " Back to error 2

Tips

  • :clist shows all quickfix entries
  • :cc N jumps to entry number N
  • ]q and [q are unimpaired-style mappings (with vim-unimpaired plugin)
  • The location list (:lnext/:lprev) is the per-window equivalent

Next

How do you yank a single word into a named register?