Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim system register * and + not working

Tags:

vim

copy

freebsd

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

like image 944
bvpx Avatar asked Aug 22 '13 15:08

bvpx


People also ask

How do I enable clipboard in Vim?

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 .

How do registers work in Vim?

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.

How do I delete a register in Vim?

To clear the a register, for instance, I type q a q to set the a register to an empty string.


2 Answers

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.

like image 68
blankblank Avatar answered Oct 07 '22 13:10

blankblank


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!

like image 37
Christopher Shroba Avatar answered Oct 07 '22 14:10

Christopher Shroba