vimtricks.wiki Concise Vim tricks, one at a time.

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 sets errorformat to parse GCC-style error messages and makeprg to gcc
  • :make — runs the program specified by makeprg, 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 :lmake instead of :make to populate the location list (per-window) instead of the quickfix list

Next

How do I ignore whitespace changes when using Vim's diff mode?