How do I quickly configure Vim to parse compiler errors for a specific language using a built-in compiler plugin?
Answer
:compiler
Explanation
Vim ships with built-in compiler plugins for many languages and tools — including gcc, python, cargo, eslint, tsc, and more. Running :compiler {name} loads the appropriate plugin, which sets both makeprg (what :make runs) and errorformat (how to parse the output into the quickfix list). This eliminates the need to configure these options manually.
How it works
:compiler {name}loads/usr/share/vim/compiler/{name}.vim(or a plugin-provided equivalent)- It sets
makeprgto the appropriate build command anderrorformatto match the tool's output - After loading, run
:maketo execute the build and populate the quickfix list with errors :cn/:cpnavigate between errors;:copenopens the list
Example
:compiler cargo " Load Rust compiler settings
:make build " Run cargo build, parse errors into quickfix
:copen " See the error list
Or for Python:
:compiler python
:make % " Run the current file through python
Tips
- List all available compilers:
:e $VIMRUNTIME/compiler/or run:compiler <Tab>for tab completion - Set a compiler per filetype using an autocommand:
autocmd FileType rust compiler cargo :setlocal makeprgand:setlocal errorformatlet you fine-tune after loading a compiler plugin- In Neovim, LSP diagnostics often replace this workflow, but
:compilerremains useful for non-LSP tools