Learn Vim / Fence off the block — vim

Fence off the block — vim

The answerCanonical keystrokes: j ma 3j d'a.

Try it on a real buffer

Delete the whole marked block. Move to the first CUT line (j) and set mark a (ma). Drop to the last CUT line (3j), then delete everything from here back to the mark with d'a.

keep the header
CUT this line
CUT this one too
CUT and this one
CUT the last of them
keep the footer

Canonical solution: j ma 3j d'a · target: 8 keystrokes — the fewest that solve it (every keypress counts).

Why it works

'a (single quote) is the LINE of mark a; `a (backtick) is the exact position. Operators take marks as motions: d'a deletes linewise from the cursor to the mark — a surgical “delete from here to there”.

▶ live vim buffertarget 8 keystrokes
Delete the whole marked block. Move to the first CUT line (j) and set mark a (ma). Drop to the last CUT line (3j), then delete everything from here back to the mark with d'a.

Reading about keystrokes doesn't build keystrokes. Try this in a real vim buffer right now — the “Fence off the block” mission takes about a minute.

Sign in free to practice →

Keep going