Marks
Marks in Vim are kind of like bookmarks. They are used to tag a location in your document that you might want to return to later.
Vim has two types of marks: marks that are manually set by you, and marks that are automatically set by the editor. Both types are useful in different situations.
As an example of where you might use marks, consider the following situation: you’re trawling through a codebase hunting for a bug, and you’ve just spotted a function that warrants some further analysis. But before you start debugging that function, there’s a few other places you’d like to look first — perhaps further down the call stack, or elsewhere in the current buffer.
In this kind of situation, it would be a good idea to set a mark on the interesting function so that you can easily return to it. Setting a mark means that returning to the interesting function is just two keystrokes! That’s much easier than finding it again by scratch, or grepping for it.
So, how do we set a mark? For now, we’re going to consider just two keymaps:
- mm sets the mark
- 'm jumps us back to the line where the mark is set
Work through the checklist below. The editor holds a suspicious-looking function — move onto it, drop a mark with mm, wander down to the bottom of the buffer, then snap straight back with 'm.