Created: 2013-01-16 — modified: 2013-01-16 — tags: vim
How to copy-paste text from one place to another, replacing what's already there
Consider the following situation:
f(good); ...<somewhere below>... f(bad)and you want to change it to this:
f(good); ...<somewhere below>... f(good)
Usual Windows-way would be:
- select "good" and copy it to clipboard
- select "bad" and paste stuff from clipboard
How to achieve the same in Vim, without using extra "x registers?
Visual mode to rescue!
- (Y)ank (copy) "good" text (yib to (Y)ank (I)nside (B)rackets when cursor is in "good" word)
- Move the cursor to "bad" word
- Select it (in visual mode) and paste stuff (vibp to go (V)isual, select (I)nside (B)rackets, and (P)aste)
Related reading: :help v :help v_p