5

I recently started using VcXsrv with the hope of being able to grab text from vim (console mode) to the Windows clipboard via X11 forwarding (and the * register). It works...to an extent. As soon as I paste to Notepad, I lose the ability to yank to the Windows clipboard.

  • I'm experiencing this issue whether I yank text to the * register directly, or use the autoselect clipboard option. (:help options (clipboard), :help guioptions_a)
  • It doesn't appear to be tied to a specific Xserver: I've tried VcXsrv, XMing, and MobaXterm (including PuTTY w/ Moba's X Server).
  • It doesn't appear to be tied to the terminal I'm using. I've tried PuTTY and MobaXterm.
  • xclip can be used any number of times outside of vim with no issues.
  • Echoing a command to xclip seems to temporarily fix the problem. I can successfully copy yank to "* from vim again, but as soon as I paste to the Windows notepad, the problem is back.
  • ~/.vim/autoload and ~/.vim/plugin are empty.
  • I use tmux regularly, but experience this problem outside of a session as well.
  • Happens with gvim as well.

My .vimrc:

$ cat ~/.vimrc
" Default vimrc file, installed by vim spell
set mouse=a
set nocompatible
set backspace=indent,eol,start
" set autoindent
" set smartindent
set cindent
set tabstop=4
set shiftwidth=4
set expandtab
set ruler
set showcmd
colorscheme elflord
syntax enable
if &term =~ "^screen"
  set ttymouse=xterm
endif
filetype plugin on

Output of set clipboard:

clipboard=autoselect,exclude:cons\|linux

Output of vim --version:

$ vim --version | head -20
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Jul 12 2010 02:29:33)
Included patches: 1-445
Modified by [email protected]
Compiled by [email protected]
Huge version with GTK2 GUI.  Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+cryptv +cscope +cursorshape +dialog_con_gui +diff +digraphs +dnd -ebcdic
+emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path
+float +folding -footer +fork() +gettext -hangul_input +iconv +insert_expand
+jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap
+menu +mksession +modify_fname +mouse +mouseshape +mouse_dec +mouse_gpm
-mouse_jsbterm +mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte
+multi_lang -mzscheme +netbeans_intg -osfiletype +path_extra +perl +postscript
+printer +profile +python +quickfix +reltime +rightleft +ruby +scrollbind
+signs +smartindent -sniff +startuptime +statusline -sun_workshop +syntax
+tag_binary +tag_old_static -tag_any_white +tcl +terminfo +termresponse
+textobjects +title +toolbar +user_commands +vertsplit +virtualedit +visual
+visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup
+X11 -xfontset +xim +xsmp_interact +xterm_clipboard -xterm_save

Update:

:echo @* will show the contents of the * register properly even after the bug manifests, so it appears that it's not arriving in the Windows clipboard via my X servers for some reason.

3
  • I'm using VIM over mRemoteNG SSH session. And everything is working like a charm. I'm coping text via Shift+selection.
    – yegorich
    Commented Dec 7, 2013 at 9:46
  • @yegorich I know how shift selection works, but it's not what this topic is about. It's not possible to yank the entire contents of a file (including what is off screen) to the clipboard using that method.
    – Andrew B
    Commented Dec 7, 2013 at 10:41
  • 1
    I was able to make this problem go away at home by upgrading to a more recent version of vim, but I'm experiencing it again at work with RHEL5 and vim 7.0 (vim-7.0.109-7.2.el5 RPM package / vimx binary). Adding a bounty.
    – Andrew B
    Commented Dec 17, 2013 at 16:19

1 Answer 1

2

I know how shift selection works...It's not possible to yank the entire contents of a file (including what is off screen) to the clipboard using that method.

I don't know if it will work via X forwarding into windows, but try the * register for that. Go to the top, in normal (not --INSERT--) mode, "*10000yy (yank 10000 lines into register *). Register * is the X clipboard, so you can paste that anywhere in X; if you have some method of transferring that to the windows clipboard you're set.

"* is a hassle because of the shift combo. If you do this a lot, map "* to an F key or something:

:nmap <F8> "*
:vmap <F8> "*

That maps for normal mode and visual mode, so you can ctrl-v select stuff too.

2
  • I deleted the last comment after some further testing. Your suggestion bypasses the clipboard autodetection (:help guioptions_a), which is already sending the yanked text to the * register. I'm experiencing the same issue when yanking to it directly though.
    – Andrew B
    Commented Dec 7, 2013 at 11:15
  • Actually, reading that text file further, I'm misunderstanding what's happening. Pressing y isn't yanking it to *, it's simply the fact that I'm highlighting the text in visual mode. In either event, the * register is breaking after the first paste for some reason. I'll update my question with appropriate terminology.
    – Andrew B
    Commented Dec 7, 2013 at 11:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .