The quickfix list
Quickfix, in one sentence, is a list of jump targets. It has the following key strengths:
- It can be created from a number of sources
- You don’t need to have focus on it to close it, and you can open it at any time
- There are effective commands for jumping following different patterns (files, locations in files, first, last)
- It keeps history
Creation
List creation can happens in multiple ways:
- Pasting result from a telescope selector (CTRL+Q)
- Using :make to compile and capture errors
- Using :grep to search files
- Using Vimgrep
- Using :helpgrep
and there are also commands to add to the current quickfixlist, using :lua vim.diagnostic.setqflist() or using the Telescope diagnostics. The quickfix window can be opened via :copen and closed without need to focus on that window using :cclose
Navigation
Several commands are available for jumping from one quicklist location to the another one:
- :cc jump to entry (support :cc[nr] to jump to the n-th entry)
- <CR> jumps to entry under cursor, CTRL-W <CR> in a new window
- :cnext/:cprevious Jump to next/previous entry
- :cbelow/:cabove jump to entry above/before current line
- :cafter/:cabefore jump to entry above/before current position (line/column)
- :cfile/:cpfile jump to the next/previous file
- :cfirst / :clast jump to first / last entry
History
History is visible via :chistory while :colder and :cnewer let you navigate among that.
Batch operations
:cdo execute a command on each entry (i.e. :cdo s/OLD/NEW/g|w) while :cfdo once per file (`:cfdo %s/OLD/NEW/s)
Plugins
Cfilter can be used to reduce the number of entries by filtering and :Qfreplace
Location list
Location list are specific to a single file, so each buffer would have the same own location list. While commands start with :c for quickfix list, they start with :l for the location list
Advanced techniques
The quickfix and the location list can be saved :w filename and can be loaded:
- :cfile replaces the content of the quickfix list / :cgetfile add the content of the file to the quickfix list
- :cbuffer replaces the content of quickfix list from the buffer / :cgetbuffer add the content of the buffer to the quickfix list
Equivalent commands exists for location list