Make search part of an edit

0 of 4

The technique

Your textVim mode: Normal
Delete everything before keep. Before: Remove this; keep the note. After: keep the note.

The match itself stays. c/keep would delete the same text and let you type in its place.

Keys in this lesson

d/text
Delete up to a search match. Press Enter after the text.
c/text
Change up to a search match.

Before this lesson: Search foundations; operator grammar.

More about this lesson

Use a visible destination as an operator boundary and protect lookalike words.

d/pattern then Enter deletes up to the forward match, leaving the match itself. c/ does that deletion then enters Insert mode. A literal search can match part of a word; * and # use the word under the cursor. You can also combine an operator with familiar e or w motions.

Example

From Remove in “Remove this; keep the note”, d/keep then Enter preserves “keep the note”. Change uses the same destination but lets you type replacement text.

Use Reset to try again.

Guides on this topic

Exercise 1 of 4

0keys

par 7

Remove the obsolete prefix and preserve the message beginning with keep, including the archive.

Your textVim mode: Normal

Desired result

const message = "keep the note";
// Keep the archive unchanged.

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.