How do I jump back in the jumplist and automatically reveal and center the destination?
Answer
<C-o>zvzz
Explanation
Jumping backward with <C-o> is fast, but in folded or dense files it can land you in a collapsed section or near the edge of the screen, forcing extra cleanup keystrokes. Chaining zvzz after the jump creates a much smoother navigation loop: jump, reveal context, and center the line in one motion. It is a compact pattern that pays off during code archaeology and refactors.
How it works
<C-o>moves to the previous entry in the jumplistzvopens just enough folds to make the cursor line visiblezzcenters the current line vertically in the window
Together, this avoids the common "I jumped there but still cannot see enough context" problem.
Example
You jump to a definition, then traverse several references with searches and tags. When you want to return to where you came from, use:
<C-o>zvzz
Behavior:
1) Jump to previous location in jumplist
2) If location is inside a fold, open it just enough
3) Recenter viewport around that line
This is especially useful in files with aggressive manual or syntax folds, where plain <C-o> often lands out of view.
Tips
- Add a mapping if you use this frequently, for example:
nnoremap <leader>o <C-o>zvzz - The forward counterpart is
<C-i>zvzz - Pair with
:jumpswhen you need to inspect the jump stack before moving