How do I turn custom command output like file:line:col:message into a navigable quickfix list?
Answer
:setlocal errorformat=%f:%l:%c:%m | cexpr system('tool %') | copen
Explanation
Not every linter or internal script speaks Vim quickfix format out of the box. You can still make it first-class in your editing workflow by teaching Vim how to parse each output line, then loading those lines into quickfix in one command. This is a strong pattern for integrating custom build tools without installing a plugin.
How it works
:setlocal errorformat=%f:%l:%c:%mdefines how to parse each diagnostic line%f:%l:%c:%mmeans: file, line, column, messagecexpr system('tool %')runs the external command and feeds stdout into quickfix using your currenterrorformatcopenopens the quickfix window so you can jump through results immediately
Because errorformat is local here, you can tailor parsing per filetype or per buffer without globally affecting other tools.
Example
Assume your command prints:
app/main.py:12:5: undefined name 'cfg'
app/api.py:44:18: missing return type
Run:
:setlocal errorformat=%f:%l:%c:%m | cexpr system('tool %') | copen
Now quickfix entries become jump targets:
1 app/main.py|12 col 5| undefined name 'cfg'
2 app/api.py|44 col 18| missing return type
Tips
- Replace
tool %with your real command (for example, a linter or checker script) - Add this to a custom command to avoid retyping
- For complex formats, extend
errorformatwith multiple comma-separated patterns