Lorin Hochstein
Lorin Hochstein

Reputation: 59202

Vim: copy text across buffers in one command

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.

Upvotes: 8

Views: 771

Answers (1)

guessimtoolate
guessimtoolate

Reputation: 8642

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.

Upvotes: 5

Related Questions