Continuing from the previous section, we have set the x
mark:
Lets start by moving the cursor to another location in the buffer:
then return to the mark. To return to the mark, type a backtick followed by the name of the mark,
`{a-zA-Z0-9} For example, to jump back to the x
mark we previously set:
A simple mnemonic to help remember: the backtick goes back to the mark.
Jump to the line containing a mark
Although setting a mark records the exact cursor position, in many cases it is preferable to jump to the start of the line containing the mark rather than the mark itself. This is often more useful in two types of situations:
-
The mark was set to easily return to a position in the document, rather than a specific character, and
-
Writing macros can sometimes be simplified by starting from a know position in a line.
Jumping back to the line containing a mark (rather than the specific mark location) is achieved
using '
instead of ```, as in '{a-zA-Z0-9}. Repeating the previous example, first move
the cursor to another position in the file:
Then return to the marked line:
Note that the final cursor is positioned at the beginning of line 2, rather than the exact cursor position when the mark was set.
Now that we have reviewed the basic of setting and returning to marks, lets next review the various types of marks that Neovim provides.