4

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.

brillout
  • 1,414
  • 1
    If the output of vim --version returns -clipboard, that means that your vim installation doesn't include the clipboard feature. A + means that the feature is installed. – leemes May 11 '12 at 17:39
  • Ok. But it doens't mean that it cannot copy to the primary selection, right? – brillout May 11 '12 at 17:41
  • I think you can't. AFAIK, "clipboard"/"primary selection" is a feature of the X server. Vim itself is a pure terminal application and has nothing to do with your X server. But I may be wrong in this point. – leemes May 11 '12 at 17:45

4 Answers4

6

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

Felix
  • 281
Hamish Downer
  • 19,526
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.

leemes
  • 951
0

What worked for me on Ubuntu 18.04 was having one of the graphical packages installed (vim-gtk or vim-gtk3) and remove the package vim. This will set the alternative for vim from /usr/bin/vim.basic to e. g. /usr/bin/vim.gtk.

The alternative can also be selected manually with

 $ sudo update-alternatives --config vim
Murphy
  • 1,737
0

If your vim has the clipboard support you can:

:%y*

* .............. primary selection