Quickfix
Quickfix list, location list, and workflows for navigating errors and search results.
Quickfix List
Open and close the quickfix window
:copen " open the quickfix window
:cclose " close the quickfix window
:cwindow " open quickfix window only if there are errors
Navigate quickfix entries
:cnext " go to next entry (also :cn)
:cprev " go to previous entry (also :cp)
:cfirst " go to first entry
:clast " go to last entry
:cc 5 " go to entry number 5
List quickfix entries
:clist " show all quickfix entries
:colder " go to older quickfix list
:cnewer " go to newer quickfix list
Populating the Quickfix List
From make
:make " run makeprg, populate quickfix with errors
:make! " run make but don't jump to first error
From grep
:grep pattern files " run grepprg, populate quickfix
:vimgrep /pattern/ files " use Vim's internal grep
:vimgrep /TODO/ **/*.lua " search recursively for TODO in Lua files
From compiler output
:compiler gcc " set errorformat for GCC
:compiler pyunit " set errorformat for Python unittest
Location List
The location list is per-window (vs quickfix which is global).
Open and close location list
:lopen " open location list window
:lclose " close location list window
:lwindow " open only if entries exist
Navigate location list entries
:lnext " go to next location list entry
:lprev " go to previous entry
:lfirst " go to first entry
:llast " go to last entry
:ll 5 " go to entry number 5
Populate location list
:lgrep pattern files " grep into location list
:lvimgrep /pattern/ files " vimgrep into location list
:lmake " make into location list
Quickfix with External Tools
Use ripgrep as grepprg
vim.opt.grepprg = "rg --vimgrep --smart-case"
vim.opt.grepformat = "%f:%l:%c:%m"
Then :grep pattern uses ripgrep and populates quickfix.
Run any shell command into quickfix
:cexpr system('rg --vimgrep TODO')
Quickfix Do
Execute a command on every quickfix entry
:cdo s/old/new/g " substitute in every file with a quickfix hit
:cdo update " save all modified files after :cdo
:cfdo %s/old/new/g " substitute once per file (not per entry)
:cfdo update " save all modified files
Quickfix Filtering
Filter quickfix list
:cfilter /pattern/ " keep only entries matching pattern
:cfilter! /pattern/ " remove entries matching pattern
Diagnostic Integration (Neovim)
Neovim LSP diagnostics can populate the quickfix or location list.
Send diagnostics to quickfix
vim.diagnostic.setqflist() -- all diagnostics to quickfix
vim.diagnostic.setloclist() -- buffer diagnostics to location list