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 the intended number is clear and protect neighbouring text.

A count before a motion or edit repeats it: 2w, 3x or 2dd. d2w and 2dw both delete two word motions. Count only the intended region. A semantic boundary such as a word or line end is safer when the length is uncertain. One counted edit is one undo step.

Example

If exactly two obsolete lines sit above “Keep”, 2dd removes both in one edit. If there are three, the same command deliberately leaves one behind. Inspect the region before choosing a count.

Use Reset to try again.

Guides on this topic

Exercise 1 of 3

0keys

par 3

Remove exactly 2 obsolete lines. Keep both neighbouring lines.

Your textVim mode: Normal

Desired result

// Keep archive
// Keep next step

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
Reset the exercise
Ctrl+Alt+P
Previous exercise
Ctrl+Alt+N
Next exercise
Enter
After a solve: the next step

Ctrl+Alt shortcuts leave Vim's own keys alone. On a Mac, Control and Option.