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
  • I'm using 50ggyy20ggp but this is too long. Commented Jun 12, 2019 at 0:30
  • Still not sure what you want, 50ggyy20ggp doesn't involve visual mode.
    – dedowsdi
    Commented Jun 12, 2019 at 0:44
  • Mistake, I exchanged the words. Commented Jun 12, 2019 at 0:49
  • 1
    Doesnt :50y work?
    – D. Ben Knoble
    Commented Jun 12, 2019 at 1:35
  • @D.BenKnoble Yes, that is what I was looking for. Commented Jun 12, 2019 at 1:43

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 you have read our privacy policy.

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