3

Let's say I'm at line 20 and I want to copy (and paste below line 20) just the line 50. I can do that with :50,50y , then paste with p in normal mode. I found this here.

I want to know if there are ways to do it without that command nor using 50ggyy20ggp (in general taking so many steps).

5

2 Answers 2

8

Copy line 50 after line 20

:50t20

Change 20 to . if you want to copy line 50 after current line.

Move around and copy line after line 20:

Go to line 20, and mark it:

mm

Move cursor to any line you want and execute an ex command :

:t'm

:h :t is synonym for :h :copy:

:[range]co[py] {address}                                *:co* *:copy*
                        Copy the lines given by [range] to below the line
                        given by {address}.

:h :[range] is current line if omitted, :h {address} is mark m in this case.

1

While the answer with :t is definitely the most convenient way to do it, if you’ve already used :yank then a good next step is probably

:put

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.