How do I navigate between errors and results in the quickfix list?
Answer
:cnext
Explanation
The quickfix list is Vim's built-in way to collect a list of positions — typically compiler errors, grep results, or linter warnings — and jump between them. Use :cnext and :cprev to move through entries, and :copen to view the list in a dedicated window.
How it works
:copen— open the quickfix window:cnext(or:cn) — jump to the next quickfix entry:cprev(or:cp) — jump to the previous quickfix entry:cfirst/:clast— jump to the first or last entry:cc N— jump to entry N:cclose— close the quickfix window
The quickfix list is populated by commands like :make, :grep, :vimgrep, or plugins like ALE and vim-fugitive.
Example
After running :grep -r 'TODO' ., the quickfix list fills with matches. Navigate them:
:copen " open the list window
:cnext " jump to next match
:cprev " jump back
:clast " jump to last entry
Tips
- Map
:cnextand:cprevfor quick access:nnoremap ]q :cnext<CR> nnoremap [q :cprev<CR> - The location list (
:lnext,:lprev) is a per-window variant of the quickfix list :cdo {cmd}runs a command on every quickfix entry — powerful for bulk edits across files- Use
:chistoryto see previous quickfix lists and:colder/:cnewerto switch between them