Linux – Can’t Copy to Clipboard from Vim

debianlinux-mintvimvimrc

I'm running Vim 7.3 under Linux Mint 13 (using MATE) and I'm not able to save text to the system clipboard. I run Vim in the terminal and copy text from the terminal with CTRLINSERT. When I select text in Vim (either with the mouse or in visual mode), CTRLINSERT doesn't copy any text. In addition when I right-click, Copy is grayed out. Further, I can't write to the system buffer by yanking to the corresponding register using vim commands. However, I'm able to paste while in insert mode (using SHIFTINSERT or right-click paste). I'm also able to copy text directly from the terminal using the same technique, just not text from Vim.

Here is my current ~/.vimrc. The relevant part is most likely set clipboard=autoselect,unnamed,exclude:cons\|linux. If I put finish at the top of my ~/.vimrc, I have the same issue, so I think the line is wrong, but I've tried set clipboard=unnamed and had the same behavior.

Could there be another config file affecting Vim's behavior? How can I change my ~/.vimrc to allow me to copy text from Vim?

Best Answer

I believe your copy problem is caused by:

mouse=a 

in your .vimrc This sets your vim into visual mode whenever you select something with the mouse. And for some mad reason one is not allowed to copy when in visual mode. You can get around it by holding down shift when selecting text not to go into visual mode allowing you to use the copy menu.

or you could change to:

:set mouse=v

and copy will work again. add it to your ~/.vimrc file if you want it to be permanent