How do I set up Vim to parse errors from my compiler or linter into the quickfix list?
Answer
:compiler gcc | :make
Explanation
Vim ships with built-in compiler plugins that configure makeprg and errorformat for popular tools. The :compiler command loads the appropriate settings, and :make then runs your build tool and parses its output into the quickfix list. This gives you one-keystroke jump-to-error without any plugins.
How it works
:compiler gcc— loads the GCC compiler plugin, which setserrorformatto parse GCC-style error messages andmakeprgtogcc:make— runs the program specified bymakeprg, captures its output, and populates the quickfix list with parsed errors and warnings
After :make, use :cnext and :cprev to jump between errors directly in your source files.
Example
Set up for a Python project using pylint:
:compiler pylint
:make %
Vim runs pylint on the current file, parses the output, and you can navigate errors with :cn and :cp.
For a Go project:
:compiler go
:make
Tips
- List all available compiler plugins with
:echo globpath(&rtp, 'compiler/*.vim') - Common built-in compilers include
gcc,javac,pylint,go,rustc,tsc,ruby, and many more - Override just the build command while keeping error parsing:
:set makeprg=make\ -j4 - Set a compiler per filetype in your vimrc:
autocmd FileType go compiler go - Use
:lmakeinstead of:maketo populate the location list (per-window) instead of the quickfix list