Solved What is the easy way to enable clipboard on Vim

Hi,

I'd like to enable clipboard for vim.

Originally I installed vim via package and lately installed many plugins on it. Now, instead of a fresh installation by compiling source, I'd like to enable the clipboard on top of existing vim.

Any easy way?
 
Code:
set clipboard=unnamedplus
in your $HOME/.vimrc
 
Code:
set clipboard=unnamedplus
in your $HOME/.vimrc


Sorry for not being clear. I think the problem is the clipboard is not compiled into package.

Code:
% vim --version | grep clipboard
-clipboard         +keymap            +printer           +vertsplit
+emacs_tags        -mouse_gpm         +statusline        -xterm_clipboard
 
The viminfo file stores what is in the vim yank buffers (not X11 clipboard).

You can force write the viminfo file with :wv. Then you can either open up a new vim instance or use :rv to reload the viminfo file.

Note that by default the amount you can yank into viminfo is limited. You can increase that by adding <1000 to your viminfo variable i.e: set viminfo='20,<1000

Another method is to replace the Y, D, P keys to read / write to a file instead. I actually do this in (n)vi but it should translate to Vim. If you want to copy to outside of vim, you can probably script it to add the contents of these files to the X11 clipboard.
 
Hello:

Today I faced the same situation where I needed to be able to access my desktop environment (MATE) clipboard, just as I do in another laptop with different OS.

TL;DR: you need a different package instead of the vanilla vim-8.2.4851. In my case, it was vim-gtk3-8.2.4851. Use pkg search vim in order to see which one is appriate for your desktop environment.

Details:

Normally, from inside vim I can select something and press "+y in order to have it copied into the DE's clipboard. Then, I can go to any other app (E.g. Pluma) and use Ctrl+v.

It also works the other way around, I copy something from any app in the desktop environment (Ctrl+c), then I can paste it in vim using "+gp, which will have a similar effect as Ctrl+v, but will avoid undesired indentation and new lines to be inserted if you are copying code between apps.

Initially I had installed vim-8.2.4851 using pkg. This resulted in -xterm_clipboard. After installing vim-gtk3-8.2.4851 (which automatically removed vim-8.2.4851), I have +xterm_clipboard enabled.

I hope this helps.
 
For me,
vim-gtk3-9.0.0379
work.

in visual mode:

"+p for pasting from the clipboard
"+y to copying to it

any other version of vim did not do it.
 
Back
Top