Learn Practice Daily golf Reference
Insert mode power·Lesson 1 of 4·9 min·0/8 exercisesPro

Fix it without leaving Insert

The typing keyboard has buttons of its own: Ctrl-h rubs out a character, Ctrl-w a word, Ctrl-u everything typed on the line, and you keep typing.

Scene

Monday, 9:00 a.m. The investors come on Friday, and the demo is you, on a projector, building a feature live. The first rehearsal goes fine until the first typo. You leave Insert mode, move back, fix it, come back in, find your place. On the big screen, the whole room watches the cursor go the long way round for one letter.

The keyboard in Insert mode has a few buttons of its own.

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 last highlight again.
press the keys…2 keys
1 of 2
Highlight the last highlight again.

Buttons on the keyboard

In Normal mode the keyboard is a remote; in Insert mode it types. But the typing keyboard has a few buttons of its own, Ctrl chords that act instead of typing, so you can fix things without leaving Insert mode. Ctrl-h rubs out the character before the cursor, like Backspace. Ctrl-w rubs out the whole word before it. You keep typing straight after.

Before
const eta = minutes + travle
ACtrl-w
const eta = minutes +
rideTime(zone)Esc
const eta = minutes + rideTime(zone)
You typed travle. Ctrl-w rubs out the word, and you type the right one without ever leaving Insert mode.
Try it

Wrong word, right away

Each goal starts in Insert mode, just after you typed a word wrong. Ctrl-w and type it again, then Esc.

1 of 5Change the red text to em
9export const menu = [
8 { id: "al-pastor", name: "Al Pastor", price: 9.5, spicy: true },
7 { id: "veggie", name: "Garden Veggie", price: 8.25, spicy: false },
6 { id: "carnitas", name: "Carnitas", price: 10, spicy: false },
5];
4
3export function findItem(id: string) {
2 const item = menu.find((m) => m.id === id);
1 if (!item) throw new Error("not on the menu: " + id);
10 return itme;
1}
INSERTLoading the editor…1/50.0s10:14

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

Check yourself

How much does it rub out?

1return price + taxx
NORMAL
Keys pressed: ACtrl-wEsc

You're typing at the end of return price + taxx and press Ctrl-w. What's left?

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

Take back the whole go

Ctrl-u rubs out everything you typed on this line since you came into Insert mode: the whole attempt, when the line went wrong from the start. What was on the line before you started typing stays. (If you didn't type anything yet, it rubs out what's before the cursor instead.)

Check yourself

What survives?

1const eta = minutes +
NORMAL
Keys pressed: Aridtmie(zoen)Ctrl-uEsc

You typed const eta = minutes + a while ago. Now you press A, type ridtmie(zoen), see the mess, and press Ctrl-u. What's left on the line?

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

Start the line again

Lines that went wrong from the start. Each goal begins in Insert mode at the end of the line: Ctrl-u, type it right, Esc. On the last one, the start of the line was typed earlier and is fine.

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.

Which button?

Three buttons, three sizes of mistake. One character too many: Ctrl-h. A word typed wrong: Ctrl-w, and type it again. A line that went wrong from the start: Ctrl-u, and type it again. Pick the one that rubs out just enough.

Try it

Just enough

Six lines, each just gone wrong in a different way. Each goal starts in Insert mode, at the mistake. Rub out just enough, type the rest, 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.

From memory

Insert-mode buttons, from memory

You're in Insert mode, mid-sentence. Press the keys.

Rub out the word you just typed.
scroll here, then press the keys
1 of 3
Rub out the word you just typed.
Challenge

Rehearsal

The feature you'll build live on Friday, typed line by line. Each line has just gone wrong somewhere: fix it without leaving Insert mode, finish the line, Esc.

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.

Rehearsal oneFinish the exercise above to see it.

Extra practice optional

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

Endless

Typos, endlessly

Endless words typed wrong a moment ago.

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.