How do I lazy-load cfilter from vimrc without interrupting startup when it is unavailable?
Answer
:packadd! cfilter
Explanation
If you share a Vim config across machines, optional plugins can cause noisy startup behavior when a package is missing. :packadd! solves this by attempting to load a package silently, so your config remains portable. This is useful for built-in optional runtime plugins like cfilter that you only need in quickfix-heavy workflows.
How it works
:packadd! cfilter
:packaddloads an optional package frompack/*/opt/!makes the command silent when the package is not foundcfilterprovides:Cfilterand:Lfilterfor narrowing quickfix/location lists
Place this near mappings that depend on :Cfilter, so your setup works where available and degrades cleanly where it is not installed.
Example
In your vimrc:
packadd! cfilter
nnoremap <leader>qe :Cfilter /ERROR/<CR>
On systems with cfilter, <leader>qe filters quickfix entries to errors. On systems without it, startup still succeeds and you can guard the mapping separately if needed.
Tips
- Prefer
:packadd!for optional, environment-specific tooling - Use plain
:packaddwhen missing packages should fail loudly during setup