Now that we have seen how the jump list is created and how to traverse it, there is one last topic: what is a jump? While it might seem obvious, the answer is not quite as clear as one might think.
Conceptually, one might expect the jump list to work like web browsing history, recording each location that we navigate to. This, combined with prioritizing recent jumps (as discussed in a previous section) would probably provide the most consistent and logical user experience. Unfortunately, jump list behavior is a bit more nuanced than that. For example, in the following example we jump down a few lines, then across to the end of a line:
Although we jumped to locations in the buffer, the jump list in step 3 did not record any of these movements. What happened? The types of movements we made in in the previous example are "close-range" jumps, which are very common when editing documents. The convenience of using the jump list in these situations is outweighed by the sheer volume of entries that this would add to the jump list, making it less efficient in the situations where it is needed.
The decisions about which commands update the jump list and which don't seems to have been somewhat arbitrary, but here is a list of those that do:
Marks
Jumping to a mark updates the jump list, providing a second option for accessing marks that are returned to often. As a quick refresher, here are the basic operations for jumping to a mark:
Command | Action |
---|---|
'x | Jump to the start of the line containing mark x |
`x | Jump to mark x |
We should point out that there are variants of each of the preceding operations that allow you to
jump to marks without affecting the jump list: simply precede each operation with a g
(for
example, g`x) These can be handy and keep your jump list clean when writing macros or other
situations where marks might be used as placeholders, rather than actual jump locations.
"Window" Motions
Although line-related vertical motions such as j do not update the jump list, "window" motions that move the cursor relative to the window do. For example, these all update the jump list:
Command | Action |
---|---|
[n] H | cursor to line N from top of screen |
M | cursor to middle line of screen |
[n] L | cursor to line N from bottom of screen |
Which are roughly equivalent to these, which update the jump list as well:
Command | Action |
---|---|
[n] gg | cursor to line N, default first line |
[n] G | cursor to line N, default last line |
Finally, if your cursor is located in a filename you can jump to if using gF, which will also update the jump list.
Searching
Searching can be an effectively way to quickly move the cursor a long distance within a document, so these operations update the jump list. Searching can be forward or backwards, and locations visited while repeating the searching using n and N do as well.
Command | Action |
---|---|
/{pattern} | search forward for the Nth occurrence of {pattern} |
?{pattern} | search backward for the Nth previous occurrence of {pattern} |
[n] n | repeat the latest '/' or '?' N times |
[n] N | repeat the latest '/' or '?' N times in opposite direction |
Text Objects
motions over text objects are also recorded in the jump list:
Command | Action |
---|---|
[n] ( | cursor N sentences backward |
[n] ) | cursor N sentences forward |
[n] [[ | cursor N sections backward |
[n] ]] | cursor N sections forward |
[n] { | cursor N paragraphs backward |
[n] } | cursor N paragraphs forward |