Vim: Replacing a line with another one yanked before

Vp: select line, paste what was yanked


What I would do :

  1. aG
  2. Y
  3. xG
  4. Vp

You don't have to leave normal mode, but it does yank the line. You can however use V"0p which will always put the line yanked in step 2.


This has the additional disadvantage that line X is now in the default register, which is annoying if I find another line that should be replaced with A.

To delete text without affecting the normal registers, you can use the Black hole register "_:

"_dd