I often find myself in a situation like this:
line i want to yank
.
.
.
[cursor position]
I want to yank the line and paste to [cursor position]
.
I'm doing that with [n]k
, Y
, [n]j
, p
. That's a lot of typing ;). Before, I was using:
:[line number]Y
and then pasting, but that doesn't work with relative line numbers (relativenumber
option).
What's the fastest way to do such yanking/pasting while relative numbers are ON?
If the line is within sight (before or after cursor position), I normally just search for it (?line i want
), yank, then go ``
(back to previous position), then p
.
I'll try this:
significant patten
to search backward :/your desired search for the specific line/ y
or
:N y
(where N
is the specific line number) will copy the specific line (and it can be a range too). Now you hit p to paste it. This way you does not move the cursor.
When the number of the line to copy is known (whether it is absolute or
relative), a convenient way to duplicate that line is to use the :copy
command. For example, the Ex command below copies the line which is four
lines above and pastes it below the current one.
:-4t.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With