Sunday, April 22, 2012

Re: gvim auto copy selected text to clipboard

On 2012-04-22, Chris Jones wrote:
> On Sun, Apr 22, 2012 at 02:11:47PM EDT, Gary Johnson wrote:
>
> [..
>
> > > If you add both of them (i.e. unnamed and unnamedplus) you will get
> > > what you want as I already pointed.
>
> > I thought I also tried that when you first posted it.
>
> > I thought I set both, yanked text from one vim instance with 'Y', then
> > tried [..]
>
> Hello Gary,
>
> That's a lot of 'thinking', don't you think..: no offense meant.. :-)

Hi Chris,

What are you, my English teacher? It's probably a defensive habit
to give myself wiggle room. (Note the careful use of "probably"
instead of "think".) You want to be my shrink, too? No offense
taken. And none intended, honestly.

> The ':registers' command is the healthier methodology when monitoring
> cut's, copy's & paste's.
>
> Whatever I do, mouse or nomouse, keyboard, joystick... -) .. the ':reg'
> command lets me see exactly what is going on.. And if I'm not sure I get
> to :reg a second time, even a third time for free..
>
> I used to have problems with the different copypaste scenarios, but now
> that I use ':reg' on a regular basis, I always seem to end up with the
> copied stuff available somewhere or other.

Good idea. With that, I did some experimentation.

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

Copy text from a GNOME Terminal by dragging the mouse over it
with the left button held down.

":registers" shows selected text in the * register. The
contents of the + and " registers are unchanged from before the
copy operation.

":put" pastes the contents of the + register, not what I wanted.

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

Copy text from a GNOME Terminal as before. ":registers" shows
the same results as before, as expected.

":put" again pastes the contents of the + register.

Case 3:
clipboard=unnamed,autoselect,exclude:cons\|linux

Copy text from a GNOME Terminal as before. ":registers" shows
the same results as before, as expected.

":put" now pastes the contents of the * register.

So it appears that the only way to paste from the * register without
explicitly naming it is to exclude "unnamedplus" from the
'clipboard', and that means that unnamed yanks from Vim go only to
the * register and not the + register, which then means that Ctrl-V
in Firefox won't paste that yanked text. That's really fine with me
since I paste into X applications other than Vim with the middle
mouse button, not Ctrl-V, but it's not what the OP wanted.

By naming registers, you can copy and paste any way you like in Vim,
but I don't see a way to copy from Vim to another X application, or
from another X application to Vim, without having to know about both
the + and * registers. It would be nice if there was some way to
avoid all that thinking.

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:

Post a Comment