Vim: remote Yank line without moving

Suppose I have the following (* = cursor):

... * Kittens Puppies Humans ... 

How do I yank "People" (cursor relative to the third line), leaving the cursor in place?

Preferably one team or one (common) team.

+4
source share
3 answers

Try the following:

 :+3y 

He uses a range of +3 , which is the point at which he will start sticking out. and by default it makes one line.

UPDATE If you want to copy the second and third lines without moving the cursor, you must use the same command, but with a range of two points, for example:

 :+2,+3y 

It will copy both Puppies and Humans .

+10
source

Now, for those who are wondering, based on Birei’s answer, you can also do :ny , where n is the number of the line you want to pull out. This is actually what I was looking for when I came to this page, and is useful if you have set number enabled and you don't want to read relative strings.

Now, I wonder how to execute this yank in a particular register !: D

+3
source

My LineJuggler plugin combines yanks and puts in various short mappings; for example, using 3[f you can get a line 3 lines below the current line and place it under the current line.

+2
source

Source: https://habr.com/ru/post/1469038/


All Articles