Reputation: 49
I want to yank multiple lines with a colon command into the UNIX-clipboard without visual mode, like this:
:1,4"+y
or
:1,$"+y
The clipboard is active --> echo has('clipboard')
returns 1
I'm on raspberry pi and tried gvim and vim. Can anybody shed some light onto this? Thank you and kind regards!
Upvotes: 1
Views: 367
Reputation: 28490
I think the other answer is amazing! I didn't know of the :y
ex command.
Just for completeness, an alternative a bit more verbose is that you can yank in the default register "
(i.e. as you would do normally in Vim-only workflow) and then just copy the content into the other register via :let @+ = @"
.
Upvotes: 0
Reputation: 76864
This is possible with the :yank
command, which can be abbreviated :y
. It takes as its argument the register without the "
. So, your examples could be written as so:
:1,4y +
:1,5y +
While it's possible to do this with the :normal
command to do this with something like :normal 1G4"+yy
, this would be a lot more complex and needlessly so. :yank
is simpler and more flexible if you're fine with linewise operations.
Upvotes: 7