We saw in the previous section how the jump list records each jump that we make, and how we can review current jump using the :jumps command. In this section we will look at how to traverse the jump list to easily navigate back to previous locations in our project.
Neovim provides two commands for traversing the jump list, forwards and backwards, respectively:
Command | Action |
---|---|
C-O | Jump one step backward within jump list |
C-I | same as <Tab> |
Let's see how these work. For reference, here is the most recent jump and the current state of the jump list:
Our most recent jump was from the <meta>
tag to the <head>
tag, so let's hit C-O to traverse
backwards one step, returning to the <meta>
tag, then check the jump list:
Comparing the new jump list to that in step 12, we can see a few interesting things. First, as
before the line we just jumped from now appears at the top of the list. However, two things are
different: First, the >
marker has moved up one step, and now has the number 0
next to it.
Second, the numbers assigned to each jump count the number of steps away from step 0.
This is actually how the jump numbers have been computed all along. However, since (up to now) we have always been at the top of the jump list, we only saw one half of the counts.
Let's see how to use the jump numbers. Like many commands, C-I and C-O accept
counts, allowing us to quickly jump directly to a specific location while traversing the jump list
list. To jump directly to a specific jump in the list, simply prefix the appropriate command with
the jump number. For example, to jump directly to the <html>
tag we simply check the jump list to
see that this location is currently numbered 2
, then execute 2C-O:
As expected we have jumped back to the desired location. After making a few edits we can quickly
return to our original location (the <meta>
tag) by hitting 2C-I, then continue editing:
Finally, from time to time one might want to clear the jump list and start fresh. This can be achieved using the :clearjumps command.
Now that we have seen how the jump list is created and organized, as well as how to traverse it, there is the final topic to discuss: what does Neovim consider to be a jump?