Count a known region

0 of 3

The technique

Your textVim mode: Normal
Delete the two obsolete lines at once. Before: // Obsolete first / // Obsolete second / // Keep. After: // Keep.

Count the lines first. With three obsolete lines, 2dd would leave one behind. One u undoes the whole counted delete.

Keys in this lesson

3x
Delete three characters.
2dd
Delete two lines.
d2w
Delete two words. 2dw does the same.

Before this lesson: Compose an edit.

More about this lesson

Use a count when you know exactly how many, and leave the text around it alone.

A number before a motion or edit repeats it, as in 2w, 3x or 2dd. d2w and 2dw both delete two words. Count only what you want to change. When you're not sure how long it is, a word or line boundary is safer. A counted edit is one change, so one u undoes it.

Example

If exactly two obsolete lines sit above “Keep”, 2dd removes both in one edit. If there are three, the same command leaves one behind. Look at the lines before you pick a count.

Use Start over to try again.

Guides on this topic

Exercise 1 of 3

0keys

par 4

The old tracker is gone for good. Delete the three lines about it.

Your textVim mode: Normal

Make it look like this

import { plausible } from "./plausible.js";

export function trackPurchase(order) {
  plausible("Purchase", { props: { total: order.total } });
}

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.