Tuesday, September 20, 2011

clipboard=unnamedplus, v:register and yanks

Sorry if this shows up twice, used the wrong email account to send it the first time.


Vim 7.3.1-315

unnamedplus    A variant of "unnamed" flag which uses the clipboard
        register '+' (|quoteplus|) instead of register '*' for
        all operations except yank.  Yank shall copy the text
        into register '+' and also into '*' when "unnamed" is
        included.
        Only available with the |+X11| feature.
        Availability can be checked with: >
            if has('unnamedplus')

So if I read that correctly, when using unnamedplus all yank operations should use the '*' register and not the '+' register.

The register contents behaviour I see is also correct (will demonstrate below).

But what appears to be wrong is the value of v:register.

gvim -u NONE -U NONE --noplugin -N

Create a new buffer with the following lines:
1
2
3
4
5

:set clipboard=
:echo v:register
"

Go to first line, yy
:echo v:register
"
:echo @"
1

Go to 2nd line, "ayy
:echo v:register
a
:echo @"
2
:echo @a
2


Good.


:set clipboard=unnamedplus
:echo v:register
+
Go to 3rd line, yy
:echo v:register
+
:echo @"
3
:echo @+
Something else
:echo @*
Something else


Go to 4th line, dd
:echo v:register
+
:echo @"
4
:echo @+
4
:echo @*
4



So, referring back to the text again:
unnamedplus    A variant of "unnamed" flag which uses the clipboard
        register '+' (|quoteplus|) instead of register '*' for
        all operations except yank.  Yank shall copy the text
        into register '+' and also into '*' when "unnamed" is
        included.


If the + and * registers are not modified by yank operations, then shouldn't v:register = " when yanking text (3rd line in the above sample).  Since @+ is not modified at all.

Thanks,
Dave


No comments:

Post a Comment