I would like to substitute a word in-place. For example, after yanking some word by pressing yw and then setting a cursor on some other word, I would like to press something so that substitution will happen. (e.g. SOME_KEYw where w is really w and SOME_KEY is some key). I would not like to switch into Insert Mode.
I am not interested in the :%s/oldword/newword/gc
solution. I need interactive in-place substitution!
Answer
What you are looking for is described in Vim Tip 605.
If you yank the first word with yiw, you can then replace another word with the first one by typing viwp.
If you leave out the i, yw will also yank the whitespace after your word and when pasting this you get too much spaces. Therefore, use i to select the inner word.
No comments:
Post a Comment