Goal: Select multiple words, one at a time, then replace them all.
I'm new to Vim; I come from Visual Studio. I would like to achieve one important feature that helped me a lot in my productivity: Select multiple words, one at a time, and then replace them all.
I know there is a Vim way of replacing using:
:% s/target-word/replacement/gc
But as you can see it's still a lot to write compared to its counterpart in VS Code. Could someone help me with a vim script or a plugin to achieve this in the most similar way?
- imagine that I already have selected the word with
viw
, for example. - then I want to have a single command to select the next match.
- then start writing and see those changes written in real-time or after hitting
Esc
.
[Edit] Accepted answer
Thanks D. Ben Knoble; you provided to me the more convenient and practical answer. As the main goal is to change a word locally, the combination *cgn
Is perfect.
As I'm changing the also the current word and *
jumps me to the next match, what I add to go back to that word is Ctrl + N
.
* Ctrl + N cgn
then .