How do I cycle through my jump history in Vim?
Answer
<C-o> and <C-i>
Explanation
Vim maintains a jump list of positions you have visited. <C-o> goes back to previous positions and <C-i> goes forward, like a browser's back and forward buttons.
How it works
<C-o>jumps to the previous position in the jump list (older)<C-i>jumps to the next position in the jump list (newer)- Jumps are recorded when you use commands like
G,/search,n,{,},%, marks, etc.
Example
You jump from line 10 to line 50 with 50G, then to line 100 with 100G. Pressing <C-o> takes you back to line 50. Pressing <C-o> again takes you to line 10. Pressing <C-i> goes forward to line 50.
Tips
:jumpsshows the full jump list:clearjumpsclears the jump list- Small motions like
j,k,wdo not create jump entries - The jump list is per-window