Using Jumps


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.

How useful was this tip?

Average rating 3.5 / 5. Vote count: 392

No votes so far! Be the first to rate this tip.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Written by

Andy Libby

36 Posts

Rider of bicycles. Writer of code. User of Vim.
View all posts