Build one repeatable change

0 of 4

The technique

Your textVim mode: Normal
Add a semicolon to both lines. Before: apples / pears. After: apples; / pears;.

The dot repeats the whole change, including the jump to the end of the line that A makes.

Keys in this lesson

.
Repeat the last change.
A
Insert at the end of the line.

Before this lesson: Insertion doors and character search.

More about this lesson

Make a change once, in a way the dot can repeat.

The dot repeats your last complete change, from the command that starts it to Esc. A includes the jump to the end of the line, so it works on lines of any length. I does the same for the start of the line. i types where the cursor is, so move to the right place before you repeat it. O opens a line above the one you're on. The dot repeats the change, not the moves you made before it.

Example

Press A, type a status at the end of the line and press Esc. Then press j and the dot. It works even if the next line is a different length, because A does the jump to the end for you.

Use Start over to try again.

Guides on this topic

Exercise 1 of 4

0keys

par 7

Turn off the two lines that log every event, so they stay in the file for debugging.

Your textVim mode: Normal

Make it look like this

import { getConsent } from "../privacy/consent";

const ENDPOINT = "https://stats.northwind.shop/collect";

// Sends one analytics event, if the visitor said yes to statistics.
export function track(name, props = {}) {
  // console.log("track", name);
  // console.log("props", props);
  if (!getConsent().statistics) return;
  const body = JSON.stringify({ name, props, page: location.pathname });
  navigator.sendBeacon(ENDPOINT, body);
}

Yours

Par

Keyboard shortcuts
Ctrl+Enter
Check the result
Ctrl+Alt+U
Undo the last change
Ctrl+Alt+H
Show the next hint
Ctrl+Alt+R
Start the exercise over
Ctrl+Alt+P
Previous exercise
Ctrl+Alt+N
Next exercise
Ctrl+Alt+K⌃⌥K
Show the keyboard shortcuts
Ctrl+Alt+F⌃⌥F
Turn focus mode on or off
Ctrl+Alt+S⌃⌥S
Open the editor settings
Enter
Go on to the next step after you finish

The Ctrl+Alt shortcuts don't clash with Vim's own keys. On a Mac, use Control and Option.