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!
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.