2

when I search for a word there could be many matchings but I just want to replace some of them so use

/keyword

and

n

I can visit each matching

is there any method to visit each matching and then decide whether to replace it or not?

2 Answers 2

6

This:

:%s/keyword/replacement/gc
Sign up to request clarification or add additional context in comments.

5 Comments

why I need to input this multiple times, sometimes, it can't get matching? not sensitive
and after I input n, the search won't continue
When I use this, "n" has the search skip to the next one, and "y" causes the current target to be replaced. If you'd like case to be ignored, add "i" to the flags. So :s/input/output/gci.
it seems that is only works on the words of one line, for a differnt line, I need to move the cursor to that line and input the command again
@user1769686: Oops. You're right. I forgot the % at the front. You can also do a visual region with this as well.
3

Keep pressing n until you get to the first word you want to change.

Then type cwreplacementEsc.

From then on you can type n to skip to the next match and . if you want to change it (otherwise just n again to skip to the next one).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.