Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: Yank distant line without moving

Tags:

vim

Suppose I have the following (* = cursor):

...
*
Kittens
Puppies
Humans
...

How do I yank the "Humans" (cursor relative 3rd line) while leaving the cursor in place?

Preferably in one motion or one (generic) command.

like image 495
Dane O'Connor Avatar asked Dec 07 '22 08:12

Dane O'Connor


1 Answers

Try this:

:+3y

It uses the range +3 , that it is the point where it will begin to yank. and by default it does one line.

UPDATE: If you wanted to copy both the second and third line without moving cursor, you would use same command but with a range of two points, like:

:+2,+3y

It would copy both Puppies and Humans.

like image 57
Birei Avatar answered Dec 18 '22 20:12

Birei