You are not logged in.

#1 2018-06-02 13:27:23

cuteclown
Guest

Copying to system clipboard in vim

I am trying to yank text from vim to the clipboard. I am trying to use "*yy and "+yy. These commands allow me to paste the text inside of vim, but nothing gets written to the system clipboard. Curiously, I also don't see any feedback from vim when I yank. I vaguely remember that vim used to give some message like "X linex yanked to register *" (but I'm not too sure about this). I can also copy and paste in Geany and rxvt-unicode, which *do* seem to use the system buffer.

I use the X window system, rxvt-unicode, and the zsh shell. In my .Xdefaults I have (leaving out irrelevant configuration such as colors):

URxvt.iso14755:        false
URxvt.iso14755_52:     false

! Disable Ctrl-Alt-c & Ctrl-Alt-v bindings
URxvt.keysymb.C-M-c:    builtin-string:
URxvt.keysymb.C-M-v:    builtin-string:

! Bind Ctrl-Shift-c & Ctrl-Shift-v to copy and paste
URxvt.keysym.C-S-0x43: eval:selection_to_clipboard
URxvt.keysym.C-S-0x56: eval:paste_clipboard

My .vimrc looks like

set number
set tabstop=4
tab all
syntax on
set wrap!
set shortmess-atI

I think overriding control+shift+c and control+shift+v may cause the problem. I can use control+shift+c and control+shift+v in vim as well. I would be happy to use those, but the problem is that shift+control+c copies line numbers as well.

#2 2018-06-02 13:50:34

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,475

Re: Copying to system clipboard in vim

Vim doesn't support system clipboard, you can use xclip with visual mode for copy to system clipboard

vnoremap <C-c> y: call system("xclip -i", getreg("\""))<CR>
noremap <C-V> :r !xclip -o <CR>

or
you can use gvim

Last edited by Docbroke (2018-06-02 13:51:33)

Offline

#3 2018-06-02 14:26:43

progandy
Member
Registered: 2012-05-17
Posts: 5,321

Re: Copying to system clipboard in vim

To support the clipboard register " in the terminal, you need to install vim-fakeclip from the AUR.


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#4 2018-06-02 14:55:13

cuteclown
Guest

Re: Copying to system clipboard in vim

Docbroke wrote:

Vim doesn't support system clipboard, you can use xclip with visual mode for copy to system clipboard

vnoremap <C-c> y: call system("xclip -i", getreg("\""))<CR>
noremap <C-V> :r !xclip -o <CR>

or
you can use gvim

I couldn't get xclip to work for me - to access the system clipboard I seem to have to use the -selection clipboard option - but somehow I still couldn't manage to paste the text outside of vim. Gvim works like a charm smile

progandy wrote:

To support the clipboard register " in the terminal, you need to install vim-fakeclip from the AUR.

For some reason, vim-fakeclip doesn't work for me. Again, yanking works fine inside vim, but the system clipboard is not affected. However, installing gvim (and using the normal vim) works like a charm for me.

Thanks for the replies!

Board footer

Powered by FluxBB