Vim: Replacing a line with another one yanked before
Posted
by
duddle
on Stack Overflow
See other posts from Stack Overflow
or by duddle
Published on 2010-12-26T10:44:36Z
Indexed on
2010/12/26
10:54 UTC
Read the original article
Hit count: 215
vim
At least once per day i have the following situation:
A: This line should also replace line X
...
X: This is line should be replaced
I believe that I don't perform that task efficiently.
What I do:
- Go to line A: AG
- Yank line A: yy
- Go to line X: XG
- Paste line A: P
- Move to old line: j
- Delete old line: dd
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. Yanking to and pasting from an additional register ("ayy, "aP) makes this simple task even less efficient.
My Questions:
- Did I miss a built-in Vim command to replace a line yanked before?
- If not, how can I bind my own command that leaves (or restores) the yanked line in the default register?
© Stack Overflow or respective owner