Learn Practice Daily golf Reference
Insert mode power·Lesson 3 of 4·7 min·0/6 exercisesPro

Paste and calculate

In Insert mode Ctrl-r pours a jar where you're typing: Ctrl-r" the last yank or delete, and Ctrl-r= the calculator, which types the answer to a sum; Ctrl-n finishes a word from the file.

Scene

Monday, 2:00 p.m. Third rehearsal. The demo has a moment where the special of the day goes into two places, and you retype "Birria Bomb" by hand, twice, slowly. Then the projector shows you working out four kitchens times seventy-three orders in your head.

More buttons on the typing keyboard: one pours from a jar, one does sums, and one finishes long words for you.

From memory

Warm-up from earlier chapters

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

Jump to the start of the line and keep typing there.
press the keys…2 keys
1 of 2
Jump to the start of the line and keep typing there.

Pour the jar

Remember the jar on the kitchen shelf? Every yank and delete fills it. In Insert mode, Ctrl-r followed by the jar's name pours it in where you're typing: Ctrl-r" pours the jar you know. It stays full, so you can pour it again further on. (Track 9 shows the rest of the shelf: there are more jars than one.)

Afteryi"
""Birria Bomb
After yi", the jar holds the name, ready to pour with Ctrl-r".
Try it

Pour it twice

Copy the special's name (yi"), then pour it into announce() and into the banner line with Ctrl-r", typing the quotes around it. No retyping the name.

1 of 2Type "Birria Bomb" where it's shown in green
1const special = "Birria Bomb";
1announce();
2banner.title = ;
NORMALLoading the editor…1/20.0s1:1

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

The calculator jar

One jar on the shelf works out what you write on it. Ctrl-r= opens a small prompt at the bottom of the editor: type a sum like 4*73, press ↵, and 292 is typed where the cursor is. + - * /, brackets and decimals all work.

Before
const lunchOrders =
ACtrl-r=4*73↵Esc
const lunchOrders = 292
Typing after the =: Ctrl-r=, 4*73, ↵, and the answer goes in.
Check yourself

Halves

1const perRider =
NORMAL
Keys pressed: ACtrl-r=7/2↵Esc

Seven orders split between two riders. You press Ctrl-r=, type 7/2, and ↵. What goes in?

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

Sums on the projector

Each goal starts in Insert mode where the number goes. Four kitchens times 73 orders; 5 days times 11 hours times 60 minutes; a 15% tip on 48.20. Ctrl-r=, the sum, and before you press ↵, a rough guess: is it nearer 30 or 300? Then ↵, and Esc.

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.

Finish the word

One more button for long names: type the start of a word that's already in the file and press Ctrl-n, and Vim finishes it with the next word that starts that way, looking down the file and round from the top (Ctrl-p looks up instead). A small list shows the other candidates; press it again for the next one, or just keep typing. Like Ctrl-w, the browser keeps Ctrl-N on Windows and Linux, so Alt-N stands in here.

1const deliveryFee = zone.fee;
2const total = price +
NORMALLoading the editor…2:22
Try it

Long names

Each goal starts in Insert mode. Type the first few letters of the name and Ctrl-n. On the second, two names start with deli, and the first one offered is the wrong one: Ctrl-n again moves to the next. Then finish the line and Esc.

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.

Rehearsal threeFinish the exercise above to see it.
From memory

Jars, from memory

You're in Insert mode. Press the keys.

Pour in what you last yanked or deleted.
scroll here, then press the keys2 keys
1 of 3
Pour in what you last yanked or deleted.