Marks and Position Management
Marks are named position bookmarks. Combined with the jump list and change list, they form a comprehensive position-tracking system for complex multi-file editing workflows.
Setting and Jumping to Marks
m{a-z} → Set lowercase mark (file-local)
m{A-Z} → Set uppercase/global mark (works across files)
`{mark} → Jump to exact position of mark
'{mark} → Jump to line of mark (column 0)
Special Marks (Automatic)
These are set automatically by Neovim:
| Mark | Position |
|---|---|
`. | Position of last change |
`^ | Position of last insert-mode exit |
`[ | Start of last yank or change |
`] | End of last yank or change |
`< | Start of last visual selection |
`> | End of last visual selection |
`` | Position before last jump |
The ` mark (backtick backtick)
This is the most-used special mark — it's the "return to where you just were" shortcut:
gg → jump to file start
`` → jump back to where you just were
G → jump to file end
`` → back again
Global Marks (Across Files)
Uppercase marks persist across files:
# In file1.lua
mA → set global mark 'A'
# Navigate to another file, edit something...
# Then:
`A → instantly back to file1.lua, same position
tip
Use uppercase marks for frequently-visited file positions during a working session: mE for your entry file, mL for your LSP config, mT for your test file.
Viewing and Deleting Marks
:marks → list all marks
:marks abc → list specific marks
:delmarks a → delete mark 'a'
:delmarks! → delete all lowercase marks
Marks as Range in Commands
Use marks as ranges in command-line operations:
'a,'b s/old/new/g → substitute between marks a and b
'a,'b d → delete lines between marks a and b
'a,'b normal @q → run macro on lines between marks
Position Workflow Examples
Workflow: Edit Two Files Alternately
In config.lua: mC (mark C)
In models.lua: mM (mark M)
Now jump between:
`C → back to config.lua
`M → back to models.lua
Workflow: Mark a Block Before Refactoring
Go to start of function
mS → mark start
Go to end of function
mE → mark end
Now you can refer to 'S,'E in commands:
'S,'E y → yank the function
'S,'E d → delete the function
The Change List for Precise Returns
The change list tracks every position where you made a change:
g; → go to previous change position
g, → go to next change position
:changes → show the change list
This is helpful when you want to return to "where I was last editing" — more precise than jump history.
Combining Marks with Operators
d`a → delete from cursor to mark 'a'
y'b → yank from cursor to line of mark 'b'
>`c → indent from cursor to mark 'c'
c`d → change from cursor to mark 'd', enter insert