How to jump back to where you were in Vim
In Normal mode, press Ctrl-o to go back to where the cursor was before the last jump, and again to go further back. Ctrl-i or Tab goes forward. Jumps are the big moves, such as G, gg, a search or %.

You're finishing total() in the burrito shop's order code, and the bill needs tax. The tax rate lives in another file, so you jump to the top to import it. With the import in, you want to be back on the line you were writing, without scrolling down and looking for it.
Import the tax, then finish the line
The cursor is on the return you were writing.
import { TAX } from './tax.js'; and press Escorder.jsThis editor needs a keyboard. Read on, and play it at your computer.
Which moves count as jumps
Vim remembers where you were each time you make a big move, and Ctrl-o walks back through those places. These are the big moves:
- G and gg, with or without a line number
- a search with / or ?, and n, N, * and #
- % to a matching bracket
- { and } between paragraphs, ( and ) between sentences
- H, M and L to the top, middle and bottom of the screen
- going to a mark, and opening another file, so Ctrl-o can take you back to the file you came from
Small moves don't count. j, k, w, b, f and $ leave nothing behind, even with a count like 10j, and neither does scrolling with Ctrl-d. If you got somewhere with 10j, Ctrl-o skips straight past it to wherever the last big move started.
A search, then a little walk
The cursor is at the start of the first line. In Normal mode you search with /return and ↵, go up two lines with k k, then press Ctrl-o. Which line is the cursor on?
Go back more than once, and forward again
Each Ctrl-o goes one jump further back, so after a few jumps you can retrace them in order. Ctrl-i goes forward again, for when you went one too far, and Tab does the same. A count works too: 3Ctrl-o goes back three jumps at once.
To see the trail, type :jumps. Each line is a place you jumped from, oldest at the top, and a > marks where Ctrl-o and Ctrl-i are in it. Vim keeps the last hundred jumps for each window.
Two jumps back
You're adding a new burrito under veggie, and two fixes at either end of the file come first.
; and Escmenu.jsThis editor needs a keyboard. Read on, and play it at your computer.
Flip to the last jump, or go to your last edit
Two backticks, ``, take you to where you were before the latest jump, at the exact column. Press them again and you're back where you started, so `` flips between two places, which is handy when you're comparing a function with the place that calls it. Two apostrophes, '', do the same but land at the start of the line's text.
To get back to your last edit, `. goes to the spot you last changed and '. to its line. They work however you moved away from it, even with nothing but j and k. g; steps back through your changes one at a time, newest first, and g, comes forward again. :changes lists them.
Back to the jump or the edit
The cursor is on the pastor line, in Normal mode. You add // spicy at the end with A and press Esc. Then you look at the top with gg and at the bottom with G. Now you press ``. Which line is the cursor on?
| Keys | Goes to |
|---|---|
| Ctrl-o | where you were before the last jump, then further back each time |
| Ctrl-i or Tab | forward again, after Ctrl-o |
| 3Ctrl-o / 3Ctrl-i | three jumps back / forward at once |
| `` | the exact spot before the latest jump (press again to flip back) |
| '' | the line you were on before the latest jump |
| `. / '. | the spot / the line of your last change |
| g; / g, | back / forward through your changes |
:jumps | the list of jumps, with > at where you are |
:changes | the list of changes |