brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Ctrl-o in Vim takes you back to where you jumped from

Vim
~/tips/tip-vim-jumplist

Ctrl-o

Returns to previous cursor spots after a search or a jump.

After a search, a G or a jump to another file, you usually want to go back to where you were. Vim keeps a list of those spots.

Ctrl-o
Ctrl-i

Ctrl-o goes to the previous position in the jump list, Ctrl-i (or Tab, which is the same key in a terminal) goes forward again. It works like back and forward in a browser.

Not every movement counts as a jump. Searches with / and n, G, %, { and }, :tag, and commands that open another file all do. Moving with j, k or w doesn’t, so pressing Ctrl-o takes you to the meaningful spots only.

You can see the whole list:

:jumps

The line with > is where you are now. A count works too: 3 Ctrl-o goes back three entries.

The list crosses files, which I like: open a file with gf, look around, and Ctrl-o brings you back to the first one. It survives restarts too when viminfo is enabled, the default.

This is a different list from g;, which walks through places where you changed text, not places you jumped to.

Further reading: Vim help: jump motions, Vim help: CTRL-O

Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more

More Vim tips :%s/<Ctrl-r><Ctrl-w>/newname/g /oldname find . -name "*.conf" | vim – vim --clean file.txt :set textwidth=72 All Vim tips (45) All topics

Link