Reputation: 440
After I do a replace, I'd like vim to highlight the text that has just been changed (instead of the words that match my search). Say, if I type s/old/new/
, I want new
to be highlighted (instead of old
). Is there any ways to do that?
I thought about triggering a search on new
after the replace step but that would also highlight the words that were already in the text before.
Upvotes: 0
Views: 247
Reputation: 172540
If you only want highlighting of those instances that were replaced (not all new
ones), you have to write your own :Substitute
command that records each change position (via :help sub-replace-expr
), and then builds a regular expression that only matches at those positions (using \%l
and \%c
). Doable, but quite involved.
You probably know this feature from other editors; try to live without it, it's not essential.
Upvotes: 1
Reputation: 1279
The command separator in vim is |
You can run the search after the replace in the same line
:s/old/new/ | /new
Upvotes: 0