Marks

Local marks, global marks, and mark-based navigation patterns.

Setting Marks

Set a mark at current cursor position
m{a-z}    " set lowercase mark (local to buffer)
m{A-Z}    " set uppercase mark (global — across files)

Jumping to Marks

Jump to a mark
'{a}    " jump to the line of mark a (first non-blank column)
`{a}    " jump to the exact position of mark a (line and column)

The backtick form is almost always what you want — it restores both line and column.

Lowercase vs Uppercase Marks

Lowercase marks (a-z) — local to current buffer
ma      " set mark a in this buffer
'a      " jump to mark a in this buffer

Each buffer has its own set of a-z marks. Setting ma in file1 does not affect ma in file2.

Uppercase marks (A-Z) — global across all buffers
mA      " set mark A (persists across files and sessions)
'A      " jump to mark A — switches buffer/file if needed

Global marks survive across files. Setting mA in any file overwrites the previous A mark.

Special Marks

Automatic marks set by Vim
'.    " jump to line of last change in current buffer
`.    " jump to exact position of last change
'"    " jump to position when last exiting this buffer
'^    " jump to position of last insert mode exit
'[    " jump to start of last yanked or changed text
']    " jump to end of last yanked or changed text
'<    " jump to start of last visual selection
'>    " jump to end of last visual selection
''    " jump to position before last jump (line)
``    " jump to position before last jump (exact)

Managing Marks

View all marks
:marks       " list all current marks with their positions
:marks aB    " show only marks a and B
Delete marks
:delmarks a       " delete mark a
:delmarks a-d     " delete marks a, b, c, d
:delmarks!        " delete all lowercase marks in current buffer

Marks in Ranges

Use marks to define line ranges for commands
:'a,'b d          " delete lines from mark a to mark b
:'a,'b s/old/new/g   " substitute between marks a and b
:'a,'b y          " yank lines from mark a to mark b

Practical Patterns

Mark your place before a jump — return easily
mm        " set mark m at current position

Navigate elsewhere, do work, then:

`m        " return to exact position
Use global marks for frequently visited files
mV        " mark V in your Neovim init.lua
mZ        " mark Z in your zshrc
'V        " instantly jump to init.lua from any buffer