I really enjoy Vim's incsearch
functionality. Is there a way to have it, or something similar to it, working while I do a replacement?
For example, if in normal mode I type:
:%s/potato/
Can I get all the potato
s highlighted on my file, just like they are highlighted by incsearch
when I write
/potato
?
This would already help me a lot when using regular expressions. A very very nice-to-have would be that when I write this:
:%s/potato/banana/
It would replace the potato
s with banana
s, and highlight them - maybe the replacements should be in a different color. It sould not "commit" the change until I pressed enter though).
I'm using neovim at the moment, in case it helps.
incsearch
?hlsearch
should work ootb, if I type:%s/potato/\0/
to replacepotato
with itself, then I see all matches highlighted.:/pattern<CR>
works fine then add the %s and the replace string. Thene again so does refine the search and use CTR-R/ to paste to the search part of:%s/
:%s/potato/carrot/c
will let you jump ("confirm") through your replacements (addg
to replace all instances on the same line) and withhlsearch
you'll see them in advance.