| Tip 84 | Operate on a Complete Search Match |
Vim’s search command allows us to highlight matches and to jump between them quickly, but operating on a complete match is nontrivial. See how to construct a motion that lets us operate on all matches, even if they vary in length.
Vim’s search command is convenient for jumping between occurrences of a pattern, but what if we want to make a change to each match?
In some text editors, the search command doesn’t just position the cursor on a match: it selects the whole thing, which is convenient if we want to operate on the match. By contrast, in Vim, the entire match is highlighted (as long as ‘hlsearch’ is enabled), but our cursor is placed at the start of the match. So if we want to operate on the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access