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

How do I configure quickfix parsing for grep output with file, line, and column?

Answer

:set grepformat=%f:%l:%c:%m

Explanation

When :grep output does not land cleanly in quickfix, the parser format is usually the missing piece. Setting grepformat to %f:%l:%c:%m tells Vim to parse each result as file, line, column, and message, matching common grep and ripgrep styles. This avoids broken quickfix jumps and makes multi-file triage much more reliable.

How it works

  • %f captures the filename
  • %l captures the line number
  • %c captures the column number
  • %m captures the remaining message text
:set grepformat=%f:%l:%c:%m

Example

If your grep tool emits lines like this:

app/models/user.rb:42:17:undefined method `foo'
lib/tasks/build.rake:10:3:unexpected token

With grepformat configured, :grep populates quickfix with accurate file and cursor positions, so <CR> in :copen jumps directly to the right column.

Tips

  • Pair with a custom grepprg (for example ripgrep in vimgrep mode)
  • Use :setlocal grepformat=... inside project-specific ftplugins when formats differ
  • If your tool omits columns, remove %c to keep parsing stable

Next

How do I make Vim transparently edit .gz files using built-in tooling?