level 12
Marks
Drop marks and jump back to exact positions.
Marks are bookmarks for your cursor. Drop one, wander off to the other end of the file, then snap back to the exact spot you left. The payoff shows up when a change in one place depends on something three hundred lines away and you need to bounce between them without losing either.
Setting and Jumping
m{letter} → set a mark (ma)
'{letter} → jump to the mark's line ('a)
`{letter} → jump to the mark's exact position (`a)
Lowercase marks (a–z) are local to the file; uppercase marks (A–Z) are global across files.
Special Marks
'' → jump back to where you were before the last jump
`. → jump to the position of the last edit
These two work like browser back/forward for your cursor. Marks also serve as motion targets: d'a deletes from the current line to mark a’s line.
Set and jump between marks
- On
initializeApp, pressma. - Move down to
loadConfigand pressmb. - Move to
connectDatabaseand pressmc. - Now press
'a, then'c, then'b— jumping straight to each.
goal Drop several marks and hop between them instantly.
Exact position with backtick
- Put the cursor on the
lof"localhost"and pressma. - Move to the
3in3000and pressmb. - Press
`a— you land on the exact character of marka. - Compare
'b(jumps to the line) with`b(jumps to the column).
goal 'a jumps to the line; the backtick form jumps to the exact column.
The '' and backtick-dot marks
- Press
gg, then search/step4and Enter. - Press
ciw, typephase4, pressEsc. - Navigate away with
/step1, then press`.to return to your last edit. - Press
''to toggle back to where you jumped from.
goal Return to your last edit, and jump back after navigating away.
Marks as motion targets
- On the
"/users"line, pressma. - Move to the
"/admin"line. - Press
d'a— delete from here back to marka’s line. - Undo with
u.
goal Operators accept marks as their range.