Paste and replace in Vim

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:
...<somewhere below>...
and you want to change it to this:
...<somewhere below>...

Usual Windows-way would be:
  1. select "good" and copy it to clipboard
  2. select "bad" and paste stuff from clipboard

How to achieve the same in Vim, without using extra "x registers?

Visual mode to rescue!
  1. (Y)ank (copy) "good" text (yib to (Y)ank (I)nside (B)rackets when cursor is in "good" word)
  2. Move the cursor to "bad" word
  3. 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