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 (az) are local to the file; uppercase marks (AZ) 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

  1. On initializeApp, press ma.
  2. Move down to loadConfig and press mb.
  3. Move to connectDatabase and press mc.
  4. Now press 'a, then 'c, then 'b — jumping straight to each.
normalpress i to type · hjkl to move

goal Drop several marks and hop between them instantly.

Exact position with backtick

  1. Put the cursor on the l of "localhost" and press ma.
  2. Move to the 3 in 3000 and press mb.
  3. Press `a — you land on the exact character of mark a.
  4. Compare 'b (jumps to the line) with `b (jumps to the column).
normalpress i to type · hjkl to move

goal 'a jumps to the line; the backtick form jumps to the exact column.

The '' and backtick-dot marks

  1. Press gg, then search /step4 and Enter.
  2. Press ciw, type phase4, press Esc.
  3. Navigate away with /step1, then press `. to return to your last edit.
  4. Press '' to toggle back to where you jumped from.
normalpress i to type · hjkl to move

goal Return to your last edit, and jump back after navigating away.

Marks as motion targets

  1. On the "/users" line, press ma.
  2. Move to the "/admin" line.
  3. Press d'a — delete from here back to mark a’s line.
  4. Undo with u.
normalpress i to type · hjkl to move

goal Operators accept marks as their range.