3

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.

  • 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

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

  • installing vim-gnome did it, even with -clipboard – brillout May 11 '12 at 18:14
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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.