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

How do I jump forward through the jump list after going back with Ctrl-O?

Answer

<C-i>

Explanation

Every time you make a "jump" — using G, /, %, :tag, <C-]>, or similar commands — Vim records your position in the jump list. <C-o> takes you backward through that list; <C-i> (or <Tab>) takes you forward again, restoring the position you were at before pressing <C-o>.

How it works

  • <C-o> — jump to the older (previous) position in the jump list
  • <C-i> / <Tab> — jump to the newer (next) position in the jump list
  • Together they let you navigate backward and forward through your cursor history, like a browser's Back and Forward buttons
  • :jumps displays the full jump list with relative line numbers and file names
  • The jump list holds up to 100 entries per window

Example

  1. You are editing main.go at line 42
  2. You press G to jump to the end (line 200) — position saved
  3. You use <C-]> to follow a tag to utils.go — position saved again
  4. Press <C-o> — back to line 200 in main.go
  5. Press <C-o> again — back to line 42 in main.go
  6. Press <C-i> — forward to line 200 again

Tips

  • In a terminal, <Tab> may be captured by the terminal or tmux — <C-i> is more reliable
  • Not every cursor movement is a jump: hjkl, w, b, e do NOT add to the jump list; large jumps (G, gg, /pattern, <C-d>) DO
  • Use :clearjumps to reset the jump list if it gets cluttered with noise from macros or scripts
  • The jump list is per-window — each split maintains its own history, so <C-o> in a split does not interfere with another split's navigation

Next

How do I run a search and replace only within a visually selected region?