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

How do I load shell command output into quickfix without running :grep?

Answer

:cgetexpr systemlist('rg --vimgrep TODO')

Explanation

When you already have a shell command that emits file:line:col:message records, :cgetexpr is a fast way to populate quickfix directly. This is useful when you want full control over the search command, flags, or target paths without changing grepprg globally. It also works well in temporary one-off workflows where you do not want to rewrite your editor config.

How it works

  • systemlist('rg --vimgrep TODO') runs ripgrep and returns output as a Vim list, one line per entry
  • :cgetexpr reads that list and parses each line with your current errorformat
  • Parsed entries are written into the global quickfix list, ready for :copen, :cnext, and :cprev

If your tool emits a different format, adjust errorformat first (or use a compiler plugin) so parsing is accurate.

Example

src/app.js:14:8: TODO remove debug log
src/db.js:52:3: TODO handle retries

Running the command loads both locations into quickfix, then you can jump through them immediately:

:copen
:cnext
:cnext

Tips

  • Use :colder and :cnewer to move between historical quickfix lists
  • Prefer :lgetexpr when you want a window-local list instead of global quickfix
  • Add ripgrep flags (-g, -t, --hidden) directly inside systemlist() for precise targeting

Next

How do I jump to a definition-style pattern match using Vim's define search?