A trick which will certainly power-up your Vim proficiency is to make use of jumps. Jumps are cursor movements stored in a list called the jumplist. When making certain movements, such as jumping to line 42 with 42G
, Vim will save it as a “jump” in the jumplist. You can list jumps using the :jumps
command. To move backwards through the jump list to an older jump use ctrl-o
. To move to a newer jump use ctrl-i
.
This short screencast that shows how efficient you can move back and forth through a file with the jumplist:
Many shorter movements, like regular hjkl
and those based on motions do not modify the jumplist. So their movements will not be navigable with ctrl-o
and ctrl-i
. Similarly, the colon line number (:42
) movement does not modify the jump list. Examples movements which modify the jump list are:
/pattern
searches and?pattern
searches (forward and backward pattern matching)*
and#
(forward and backward search for the word under the cursor.%
(jump to a matching enclosing character like paren, brace, bracket, etc)Any inter-file navigation like
gf
Vim will store up to 100 locations in your jump list. Realistically, you’re unlikely to use that many. But just a few taps of ctrl-o
or ctrl-i
can be an extremely efficient way to move between chunks of code or open buffers.
For more info, check out :help jumplist
in Vim.
Was this useful? Help us improve!
With your feedback, we can improve VimTricks. Click a link to vote:
Also g; and g, for change list http://vimdoc.sourceforge.net/htmldoc/motion.html#g;