Copy to Primary Selection in VIM

I tried "+y and "*y but both doesn't seem to copy into the primary selection.

Note that vim --version returns -clipboard. Not sure what this means.
Also note that I'm running VIM in a terminal.

So how do I copy text into the Primary Selection in VIM?
Goal is to copy text from VIM into Google Chrome.


Solution 1:

You need a version of vim that has +clipboard in its version. Install the vim-gnome package and you should be fine. (And you don't have to use gvim to use the clipboard, it still works when running vim in a terminal.)

Note In more recent versions, the actual package name seems to be vim-gtk and vim-gtk3 respectively (vim-gnome is a dummy package).

Solution 2:

"+y uses a special register and is part of the clipboard feature of vim. Since your version of vim doesn't support clipboard (-clipboard means, clipboard feature isn't available), you need to use something else.

You can try this plugin, which doesn't depend on the clipboard feature and should work in the pure terminal version of vim. It seems that it depends on one of the programs screen, xclip, tmux.