Here's a super useful Vim trick that requires no plugins and which will certainly power-up your Vim proficiency.
In Vim, 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
.
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
Over on VimTricks, we have a screencast and more details. Read the full tutorial.
Top comments (0)