Learn Practice Daily golf Reference
Visual mode·Lesson 4 of 7·7 min·0/8 exercisesPro

Block insert and append

Ctrl-v highlights a rectangle; I types in front of it and A after it, once, and Esc writes it on every line.

Scene

Friday, 11:30 a.m. The report template has rules. Every order id gets a Q3- in front, so the investors can tell this quarter's orders from last quarter's. Every line of the notes is a quote, with > at the start. There are hundreds of rows.

Not characters, not lines: a column, the same few characters at the same place on every line.

From memory

Warm-up from earlier chapters

Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.

Highlight the paragraph you're in.
press the keys…3 keys
1 of 2
Highlight the paragraph you're in.

A rectangle of highlight

Ctrl-v drags the highlighter as a rectangle: j and k set how many lines it covers, l and w how wide it is. Then I types in front of the block. While you type, the text appears on the first line only; when you press Esc, Vim copies it to every line of the block.

Before
2201,al-pastor,1,9.50,delivered
2202,birria,4,11.00,refunded
2203,veggie,3,8.25,delivered
2204,pollo,2,9.00,late
Ctrl-v3jIQ3-Esc
Q3-2201,al-pastor,1,9.50,delivered
Q3-2202,birria,4,11.00,refunded
Q3-2203,veggie,3,8.25,delivered
Q3-2204,pollo,2,9.00,late
A block four lines tall at the start of the rows, I, Q3-, and Esc writes it on all four.
Try it

Q3- on every row

Six rows, each needs Q3- in front of its id. From the first row: Ctrl-v, down to the last, I, type it once, Esc.

Fix the marked spots · 6 left
1id,item,quantity,price,status
12201,al-pastor,1,9.50,delivered
22202,birria,4,11.00,refunded
32203,veggie,3,8.25,delivered
42204,pollo,2,9.00,late
52205,carnitas,1,10.00,delivered
62206,al-pastor,4,9.50,delivered
NORMALLoading the editor…0.0s1:1

This exercise needs a keyboard. Read on, and play it at your computer.

Try it

Lost prefixes

Runs of lines that lost the same prefix at the same column. One block, one I.

Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.

The right edge

A types after the block's right edge instead. The ids are all four digits, so a block four characters wide covers them exactly, and A adds a column right after them: Ctrl-v, down, 3l, A, ,Q3, Esc.

Try it

A new column

The old import tool wants a quarter column after the id. Add it to the header by hand, then the rows with a block four characters wide and A.

Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.

Check yourself

Too short to reach

1abcdef
1ab
2abcdef
NORMAL
Keys pressed: Ctrl-vjjIXEsc

The block starts on the e of the first line and runs down three lines; the middle line is only two characters long. You press I, type X and Esc. What happens to ab?

Pick an answer (or press its number), then watch the engine prove it.
From memory

Blocks, from memory

Press the keys.

Put // in front of this line and the two below, in one go.
scroll here, then press the keys8 keys
1 of 3
Put // in front of this line and the two below, in one go.
Challenge

Column sweep

Eight runs of lines with a lost prefix, across the codebase.

Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.

Boss round

The template’s rules

12:00. The report as it stands: the three lines of notes become quotes (> in front of each), and the five rows get Q3- in front of their ids.

Stuck? Show a hint
Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.

Extra practice optional

The chapter is done. These rounds keep going as long as you like: stop whenever it stops being useful.

Endless

Columns, endlessly

Endless runs of lines that lost a prefix.

Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.