2

In Vim I've learned that if I want to move lines x through y after line z I can issue this command where 'm' stands for move:

:x,y m z 

Is it possible to simply copy (or yank) a range of lines and then paste them after a third line? I've tried substituting 'y' (yank) for 'm' but that doesn't seem to work. It just yanks the lines.

2 Answers 2

3

You can use either copy or t:

  • :x,y copy 3
  • :x,y t 3

Where x,y is the range of lines to copy.

  • Another solution is to hold lines in one of the registers let's say z and then put its content after line 3:

:x,y yank z

:3 put z


:help :t :help :copy :help :yank :help :put

Sign up to request clarification or add additional context in comments.

1 Comment

That's what I was looking for!
-1

:y 10 y will yank 10 lines in vim and :p will paste them

1 Comment

"y 10 y" doesn't make sense to me. Also, I'd like to do the yank and paste all on one line while also specifying the line I'd like them pasted after as I illustrated in my move command above. I'm looking for a one-liner.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.