Six ways into Insert mode
i a I A o O each start typing in a different place, so you rarely need to move first.
3:07 a.m. Your phone lights up the bedroom. The shiny new auto-formatter has run for the first time, taken one look at orders.ts, and eaten it. First letters: gone. Semicolons: gone. One comment now just says // TOD.
The build is red, the lunch rush starts at noon, and you're the only one awake who knows Vim. Grab a coffee. Tonight you learn the six doors into Insert mode.
Warm-up from earlier chapters
Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.
Before or after the cursor
You already know i inserts before the cursor. Its twin a appends after it. Same doorway, other side of the frame: pick whichever puts you at the gap with less walking.
Fill the gaps
Two letters went missing. Move to each gap and insert the letter with i or a.
This exercise needs a keyboard. Read on, and play it at your computer.
A: the door at the far end
Missing semicolons go at the end of a line. Walking there word by word and then pressing a works, but it's a long walk on a long line. A is the door at the far end of the line: one key, from anywhere on the line, that takes you to the end and into Insert mode.
Semicolon patrol
The formatter stole these semicolons. Put them back with A.
This exercise needs a keyboard. Read on, and play it at your computer.
I: the front door
I is the front door. It starts typing at the first real character of the line, stepping over the indentation the way you'd step over a doormat.
Lost first letters
Some lines lost their first letter. I puts you right where it belongs.
This exercise needs a keyboard. Read on, and play it at your computer.
o and O: a door to a new line
o opens a door onto a brand-new line below the cursor and steps you through, already indented to match. O opens one above. Both work from anywhere on the line, so there's no walking to the end first.
Leave a trail
Add the log line below the insert, then a TODO above the total.
This exercise needs a keyboard. Read on, and play it at your computer.
All six doors
Three pairs. The lowercase door and its capital always mirror each other: one before or above, one after or below.
| Opens onto | Before / above | After / below |
|---|---|---|
| the cursor | i before it | a after it |
| the line | I its first character, past the indent | A its end |
| a new line | O above | o below |
Six doors, from memory
Where do you want to start typing? Press the door.
Patch the build
The formatter hit every file: missing semicolons and missing first letters, eight repairs across the codebase before the 9 a.m. stand-up. Each one is marked; pick the door that takes you straight there.
Stuck? Show a hint
A;<Esc> for a lost semicolon, I + the letter + <Esc> for a lost first letterThis exercise needs a keyboard. Read on, and play it at your computer.
Repair the function
One function, seven wounds, three minutes until the build server checks again. Top to bottom: the first letter of function, three lost semicolons, the missing s at the end of the second item, a new line under the price line that adds the tip (sum += item.tip;), and a note above return: // tax included. The marks show what goes where. Pick the door that needs the least walking each time.
Stuck? Show a hint
I · A · a after the word · A · o · A · O (each ends with <Esc>)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.
Formatter cleanup
Replays of the night's damage, from the build logs: endless repairs, in bigger batches as you go. How long can you keep the build green?
This exercise needs a keyboard. Read on, and play it at your computer.