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.
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.
Warm-up from earlier chapters
Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.
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.
What lights up?
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?
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 hint
vf_d · from the _ of item_name: ved · vf_d · vf_dThis exercise needs a keyboard. Read on, and play it at your computer.
Down a line
The cursor is on the second 0 of 1001. You press v, j, d. What is left below the header?
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.
Shout the labels
The report wants its three labels on line 3 in capitals: refunded, Orders and Late, in that order. viw then U.
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.
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
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.
Highlighter, from memory
Press the keys.
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.
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.
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
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.