Saturday, April 21, 2012

Re: gvim auto copy selected text to clipboard

On 2012-04-21, Sergey Vakulenko wrote:
> >Normally the selection register is pasted with a middle-click of the mouse, not with CTRL-V. 'clipboard' containing autoselect should allow
> >this. I have no idea whether it is possible to paste the selection with CTRL-V, but I don't think it is Vim which controls this.
>
> Im not use mouse for copy paste. Also, i used this feature (copy on
> select) on Win XP 4 years. I cant understand how i cant do the same in
> Ubuntu.

Windows and X use different models for sharing a "clipboard" between
applications. There is only only Windows clipboard but there are
two X mechanisms: the selection and the clipboard. See :help
x11-selection" for more on this. This can be confusing because when
you "copy" in X, sometimes the copied text goes to the selection and
sometimes it goes to the clipboard. Similarly, pasting may use
either of these as the source. I'm sure it actually works very
consistently, but I've never completely understood it.

Here's what I have in my ~/.vimrc:

if has("clipboard")
set clipboard^=unnamed " The "exclude:" entry, which is present by
" by default, must be last. Therefore, put
" "unnamed" first.
endif

With that, I am able to easily yank and paste between applications
including vim and gvim. However, to paste into another X
application such as Firefox, I must use the mouse middle button.
Ctrl-V seems to use the other selection mechanism.

I tried changing "unnamed" to "unnamedplus" in the 'clipboard'
setting and was able to use Ctrl-V for pasting in Firefox, but then
was unable to use other mechanisms I was used to for copying and
pasting, so I went back to "unnamed". I didn't investigate the
behaviors thoroughly.

So I think you _can_ get copying and pasting to work well for you in
Ubuntu, but it may not work the same as it did in Windows.

Regards,
Gary

--
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: