:echo has('clipboard')
returns 1, but whenever I execute "+yy"
or "*yy"
nothing seems to be in those registers. If I use regular yy
to copy another line of text, then try to paste from the register using CONTROL+V
nothing happens. If I try "+p
vim pastes the line of text I copied using the regular yy
command.
What's going on here? I'm on FreeBSD by the way.
To copy text to the system clipboard, use "+y . The " allows you to specify the register, + is the register that represents the system clipboard, and you already know what y does. Alternatively, to tell vim to use the + register as the default register, put set clipboard=unnamedplus in your .
Vim registers are spaces in memory that Vim uses to store some text or operation details. Each of these spaces has an identifier so that it can be accessed later. When we want to reference a Vim register, we use a double quote followed by the register's name.
To clear the a register, for instance, I type q a q to set the a register to an empty string.
Your vim version may not be compiled with X11 clipboard integration.
In vim run the :version command and look for xterm_clipboard in the output. It will be prefixed with a + (supported) or - (unsupported) sign.
Another thing that could be going on is your DISPLAY
environment variable is not being set correctly. This could happen sometimes if you're running vim from tmux or screen.
Try opening a new terminal, running echo $DISPLAY
, and then from the terminal running vim, leave vim, execute export DISPLAY=:0
(but replace :0 with the output from your other terminal), and then re-enter vim and see if clipboard works by doing "+p
.
This solved my problem!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With