How do I quickly filter a quickfix list using Vim's built-in cfilter plugin?
Answer
:packadd cfilter | Cfilter /pattern/
Explanation
Large quickfix lists are hard to work with when you only care about one subset of matches. Vim ships an optional cfilter plugin that can derive a smaller quickfix list from the current one using a regex filter. Loading it on demand with :packadd keeps startup lean while still giving you a fast narrowing tool during refactors or grep-heavy sessions.
How it works
:packadd cfilterloads the optional runtime plugin for this session|chains another Ex command on the same command lineCfilter /pattern/creates a new quickfix list containing only entries whose line text matchespattern
The original quickfix list stays in quickfix history, so you can move back if needed with quickfix history commands.
Example
Imagine your quickfix list includes many lint and test entries, but you only want TODO-related items.
:packadd cfilter | Cfilter /TODO/
After running it, the active quickfix list contains only entries whose text includes TODO.
Before: 120 quickfix entries (mixed)
After: 18 quickfix entries (TODO only)
Tips
- Use
:Cfilter! /pattern/to invert the filter and keep non-matching entries. - Use
:Lfilterfor the current location list instead of the global quickfix list. - This is particularly useful after broad
:vimgrepruns where you need iterative narrowing.