Jumping to Marks


Continuing from the previous section, we have set the x mark:

Initial Conditions
I·have·always·believed,·and·I·still·believe,
that·whatever·good·or·bad·fortune·may·come·our·way
we·can·always·give·it·meaning·and
transform·it·into·something·of·value.
NORMAL40%2:21
 

Lets start by moving the cursor to another location in the buffer:

Move the cursor2b
I·have·always·believed,·and·I·still·believe,
that·whatever·good·or·bad·fortune·may·come·our·way
we·can·always·give·it·meaning·and
transform·it·into·something·of·value.
NORMAL40%2:15
 

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:

Jump back to the mark`x
I·have·always·believed,·and·I·still·believe,
that·whatever·good·or·bad·fortune·may·come·our·way
we·can·always·give·it·meaning·and
transform·it·into·something·of·value.
NORMAL40%2:21
 
info

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:

  1. The mark was set to easily return to a position in the document, rather than a specific character, and

  2. 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:

Titlek4w
I·have·always·believed,·and·I·still·believe,
that·whatever·good·or·bad·fortune·may·come·our·way
we·can·always·give·it·meaning·and
transform·it·into·something·of·value.
NORMALTop1:31
 

Then return to the marked line:

Title'x
I·have·always·believed,·and·I·still·believe,
that·whatever·good·or·bad·fortune·may·come·our·way
we·can·always·give·it·meaning·and
transform·it·into·something·of·value.
NORMAL40%2:1
 

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.