The simplest solution to this, that also works between different Linux machines through ssh
is:
Check whether vim supports X-11 clipboard: vim --version | grep clipboard
. If it reports back -clipboard
and -xterm_clipboard
you should install either vim-gtk
or vim-gnome
(gvim on arch linux)
Add the following lines to your .vimrc
:
set clipboard=unnamedplus set paste
ssh -Y machine
Now copying and pasting should work exactly as expected on a single, and across different machines by only using y
for yank and p
for paste. NB modify .vimrc
on all machines where you want to use this feature.