Monday, April 23, 2012

Re: gvim auto copy selected text to clipboard

When I read this thread I used the published line:

set clipboard=unnamedplus,unnamed,autoselect,exclude:cons\|linux

I use Mac, Win, Linux and each has different a version of [g]vim.
This "set" failed differently on each.

I read more and found if vim is compiled with "xterm_clipboard"
then the default for clipboard is: "autoselect,exclude:cons\|linux"
Otherwise it is: ""

What could be causing a failure?
The only two other options, unnamed or unnamedplus.

It turned out to be unnamedplus, and as I recently learned...
rather than test for has() or exists() I could simply use "silent!".

Now, in the Linux I am using, anytime I select and yank, or just yank,
both "* and *+ are filled. Going to any other app and paste with C-v
or middle mouse button click works.
--AND--
To my surprise, if I copy with C-c from another app like a web
browser, then go back to [g]vim, p or P or :put or :put! work!

I have the following in .vimrc
it is used on Mac, Win, and Linux
works for all gvim, MacVim and terminal vim,
depending on the compiled options.

The vmap and nmap remain for vim versions that are not gui or do not
have xterm_clipboard compiled.

if has("clipboard")
vmap ,y "+y
nmap ,p "+gP
" exclude:{pattern} must be last ^= prepend += append
if has("gui_running") || has("xterm_clipboard")
silent! set clipboard^=unnamedplus
set clipboard^=unnamed
endif
endif

Bill

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: