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

How do I jump directly to the first or last entry in the quickfix list?

Answer

:cfirst and :clast

Explanation

:cfirst and :clast jump directly to the first or last entry in the quickfix list, skipping all intermediate results. This is especially useful after a grep or compile run when you want to start from the top of the errors or skip to the final match without repeatedly pressing :cnext.

How it works

  • :cfirst — jump to the first entry in the quickfix list
  • :clast — jump to the last entry in the quickfix list
  • Both accept an optional count: :cfirst 3 jumps to the third entry

The location list equivalents are :lfirst and :llast.

Example

After running :grep TODO % **/*.go, the quickfix list might have 20 entries. Rather than:

:cnext  (× 19 times)

Jump directly with:

:clast

Or to restart from the top:

:cfirst

Tips

  • :cc {N} jumps to the Nth entry by number — useful when you know the index
  • :colder and :cnewer cycle through previous and next quickfix lists from this session
  • Use :cwindow to view the full list before deciding where to jump
  • Location list versions: :lfirst, :llast, :lolder, :lnewer

Next

How do I make Neovim restore the scroll position when navigating back through the jump list?