Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: copy text across buffers in one command

Tags:

vim

If I want to copy lines 17-19 to line 33, I can do this in one command like this:

:17,19t33

Is there an equivalent way of doing this if the destination is another open Vim buffer? For example, if I wanted to copy lines 17,19 of the current buffer into buffer #2, is there a way to do this without yanking the text, switching buffers and pasting?

Note that I typically have the source and destination files open in a split.

like image 525
Lorin Hochstein Avatar asked Mar 24 '14 17:03

Lorin Hochstein


1 Answers

Does chaining counts as a one-liner? E.g.:

:17,19y | b# | 33put | b#

Not sophisticated, but should do it. I used b# for convenience.

Kudos to Peter for pointing out a mistake I made -- I moved that initial buffer switch to the end.

like image 183
guessimtoolate Avatar answered Oct 02 '22 06:10

guessimtoolate