Step 4 of 4

Acting on a match

Acting on a match

In Vim, a search puts the cursor at the start of the match, and changing the text takes a second step to say how much of it you mean. In Helix that second step is already done: the match is the selection.

That means any command that acts on a selection works directly on a search result:

  • c deletes the match and drops you into insert mode in its place
  • d deletes the match
  • y copies it

And because n hands you the next match as a fresh selection, you can search once and then work through the file one match at a time.

Work through the checklist below. The word the is misspelled as teh twice in the editor — search for it, confirm the search with Enter (the checklist ticks off the search as soon as the pattern is typed, and Escape would leave c acting on a single character instead of the match), change the first one, then jump to the second and fix that too.

  1. Search for the typo The first teh is on line 1, and it's selected by the time you've typed /teh.
  2. Change the selection The match is already selected, so press c to replace it.
  3. Type the fix and come back to normal mode Type the, then hit Escape.
  4. Jump to the next typo The other teh is on line 2 — press n.
  5. Fix it the same way Press c, type the, and hit Escape.
Search for the typo The first teh is on line 1, and it's selected by the time you've typed /teh.

Next: Change the selection

Loading editor…