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

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

  • :chistory prints 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 :colder and :cnewer accept 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 :chistory first to survey what is available before deciding how many steps to move with :colder N
  • The location list has an equivalent: :lhistory shows the stack for the current window's location list
  • :colder and :cnewer without :chistory work too, but :chistory gives you the full picture at a glance
  • This is especially useful during multi-stage refactoring where you accumulate several :grep or :make results in the same session

Next

How do I select or operate on the content of an HTML or XML tag using text objects?