Make search part of an edit
The technique
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.