I would like to set Y and P to copy and paste directly to the system clipboard instead of vim buffer.
I don't want any additional commands. Just the normal ones, but they should copy to and paste from the system clipboard and bypass the vim buffer.
How can I achieve this?
I'm running vim on Ubuntu 10.10.
06 Answers
You can have Vim use the clipboard instead of the default register for yanking, putting, etc., by adding this command to your ~/.vimrc:
set clipboard+=unnamedSee
:help clipboard
:help 'clipboard' 2 You first need to see if vim is compiled with clipboard support, run vim --version | grep clip and see if there is a + or - in front of clipboard and xterm-clipboard.
If it has clipboard support, copying from and pasting into the * or + registers should use the system/X11 clipboards, so "*yy would copy a line and "*p would paste it.
In Ubuntu 10.10 you can install vim-gnome to have clipboard support compiled in.
1have a try :
"+y and "+pthis works for me, on Ubuntu.
1The default VIM in Ubuntu is vim-tiny, which is not compiled for system clipboard support. You need to install the full VIM and the Gnome GUI to get clipboard support:
sudo at-get install vim-full vim-gnomeAfter you install those two packages you can then use the commands that Akira and wliao mentioned.
yank to the clipboard register:
"*ypaste from the clipboard register:
"*pfor more information:
:help clipboard 6 On my Ubuntu 18.04 (GNOME Shell) this enabled clipboard:
sudo apt-get install vim-gnome
vim --version|grep clipboard
+clipboard +jumplist +persistent_undo +virtualedit
-ebcdic +mouseshape +statusline +xterm_clipboard