Ctrl + O: The Most Underrated Command in Vim
Aug. 2, 2025 by John Rei Enriquez
Working in vim, when I add a new class or function and I need to import it while in the middle of a file, I’d instinctively hit gg to jump to the top of the file, add the import, then think... wait, how do I get back to where I was again?
Most of the time, I just move the cursor over the new import and hit * to go to the next occurence or /search for the function or class name I just imported. These always felt like I am doing more than 2 steps just to go back.
Other times (when I feel like being smart), I use marks.
I would mark my spot before jumping away:
ma " mark current line as 'a'
gg " go to top of file
'a " return to mark a
It works great but I’d already be at the top of the file when I remember it. No marks to go back to
90% of the time I just hit / and go search for the new imported thing or a text I know exists in the section I was working at before. This works but it always felt like it was a workaround... that's until I discovered
Ctrl+o
This command makes vim navigation 10x easier! It feels natural and intuitive.
Here’s how I work now:
- gg to jump to top, add the import
- CTRL + o to jump back to where I was
I am already there when I think about it going back
Even better? It works across files and buffers — as long as I stay in the same window!
So I can:
- Open up search in a new buffer
- Load the file that comes up in search in the original buffer
- Scan through what I need
- Ctrl + o and I'm back to my previous file/buffer :)
Notes:
CTRL + o: jump backward in the jump list
CTRL + i: jump forward in the jump list
Vim automatically tracks cursor movements in what's called the jump list.
TLDR: If you're not already using CTRL + o in Vim/Neovim, then go head and try it now!