I'd like to pass through a text an replace word1 by word2. However, I don't want to execute this task in one pass, but rather word by word. I know I could put the cursor on the word I want, execute *, then vw and finally r words. The problem is located on this last step. If I want to look for the next words, I can't with *, because I'd replace word1 by word2. Could anyone be able to help me at this point?
Asked
Active
Viewed 344 times
1
1 Answers
8
I think you're looking for the substitute command with confirmation:
:%s/word1/word2/gc
This will substitute word2 for word1, but every time it will take you to the match and let you decide what to do.
gmeans global. It will find all matches on the line.cis for confirm. It applies the behavior described above.
See :help :substitute and :help :s_c for more info.
Tumbler41
- 7,746
- 1
- 21
- 48
nasword1is still in the search register andnwill take you to the next occurrence. – Tumbler41 Feb 22 '17 at 15:42