How do I see a summary of all previous quickfix lists from my current session and navigate between them?
Answer
:chistory
Explanation
Every time you run :grep, :vimgrep, :make, or :cexpr, Vim creates a new quickfix list and pushes the previous one onto a history stack. Running :chistory displays a numbered overview of every quickfix list from the current session, so you know what results are available before navigating back to them.
How it works
:chistoryprints a numbered list of all quickfix lists in the current session stack- The currently active list is marked with
> - Navigate between lists using
:colder [N](go back N lists, default 1) and:cnewer [N](go forward) - Both
:colderand:cneweraccept a count to jump multiple steps at once::colder 3 - Vim retains up to 10 quickfix lists; the oldest is discarded when the stack overflows
Example
After three separate searches in a session:
:chistory
quickfix list 1: :grep 'TODO' **/*.py — 8 matches
quickfix list 2: :make — 3 errors
> quickfix list 3: :grep 'FIXME' **/*.py — 2 matches
Run :colder to restore the TODO results. Run :cnewer to return to the FIXME list.
Tips
- Use
:chistoryfirst to survey what is available before deciding how many steps to move with:colder N - The location list has an equivalent:
:lhistoryshows the stack for the current window's location list :colderand:cnewerwithout:chistorywork too, but:chistorygives you the full picture at a glance- This is especially useful during multi-stage refactoring where you accumulate several
:grepor:makeresults in the same session