Learn Practice Daily golf Reference
Visual mode·Lesson 1 of 7·9 min·0/9 exercisesPro

v and a verb

Visual mode is a highlighter: v marks from the cursor, any motion drags it, and then a verb acts on what you see: d, c, y, >, or U u ~ for case.

Scene

Friday, 9:00 a.m. Quarter-end. The accountant's export is in: every order since July, one per line, and a draft of the summary that goes to the investors at five. The headers are in the accountant's words, not the report's, and half the edits are stretches of text with no name: not a word, not a string, just this bit here.

For those, Vim lets you point first.

From memory

Warm-up from earlier chapters

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

Change the text between these tags.
press the keys…3 keys
1 of 2
Change the text between these tags.

The highlighter

v uncaps a highlighter where the cursor is and marks with its narrow tip, character by character. Every motion you know drags its far end: e, f_, j, even a search. The highlight shows exactly what's marked, and nothing happens until you say the verb: d deletes it, c changes it, y copies it. It's track 3's verb-then-noun sentence the other way round: the noun first, then the verb. Esc caps the pen with nothing changed.

Check yourself

What lights up?

1order_id,item_name,quantity,unit_price,order_status
NORMAL
Keys pressed: vf_d

Predict it before the demo below: the cursor is on the first letter of order_id. You press v then f_. What is highlighted when you press d?

Pick an answer (or press its number), then watch the engine prove it.
1order_id,item_name,quantity,unit_price,order_status
NORMALLoading the editor…1:1
Try it

The report’s words

The header, left to right: order_id → id (vf_d from its start), then item_name → item, unit_price → price, order_status → status. Mark what goes, look, then d. If an operator like df_ comes to mind first, that counts too.

Stuck? Show a hintvf_d · from the _ of item_name: ved · vf_d · vf_d
1 of 4Change the red text to id
1order_id,item_name,quantity,unit_price,order_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
NORMALLoading the editor…1/40.0s1:1

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

Check yourself

Down a line

1id,item,qty
21001,al-pastor,2
11002,veggie,1
NORMAL
Keys pressed: vjd

The cursor is on the second 0 of 1001. You press v, j, d. What is left below the header?

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

Verbs for a highlight

Besides d c y, a highlight takes > and < (indent the lines it touches), and three case keys: U for upper case, u for lower case, ~ to swap. Text objects grow it too: viw highlights the word under the cursor, vi" a string's contents. So viwU shouts one word.

Try it

Shout the labels

The report wants its three labels on line 3 in capitals: refunded, Orders and Late, in that order. viw then U.

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.

Try it

Cap the pen, take it back

Two slips with the highlighter, already made. First, a highlight that wandered two lines down: put the pen down without changing anything. Then a vjd that took the end of one line and the start of the next: bring them back.

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.

From memory

Highlighter, from memory

Press the keys.

Highlight to the end of this word and delete it.
scroll here, then press the keys3 keys
1 of 4
Highlight to the end of this word and delete it.
Challenge

Mark and act

Ten stretches to delete or change and names in the wrong case, across the codebase. Use the highlighter where it helps; an operator where you can name the stretch.

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 summary

9:40. The summary, top to bottom: the heading loses (DRAFT, do not send), Al-Pastor goes lower case like the export, and the note about the harbour, from Note to the end of report, becomes Note: the harbour incident is in its own report. Highlight, look, then act.

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.