| Subject: | clipboard=unnamedplus, v:register and yanks |
|---|---|
| Date: | Tue, 20 Sep 2011 08:25:55 -0400 |
| From: | David Fishburn <dfishb...@gmail.com> |
| To: | vim_use <vim...@googlegroups.com> |
|quoteplus|)
instead of register '*' for |quoteplus|)
instead of register '*' for :help v:register mentions nothing about the *effective register*, only
the one supplied (and since 7.3.186, this considers the changed default
for the "unnamed" and "unnamedplus" values).
> v:register The name of the register supplied to the last normal
> mode command. Empty if none were supplied. |getreg()| |setreg()|
In my understanding, v:register is mainly necessary for custom
operations that work with registers, not for built-in commands like
yank. Is your inquiry about theoretical correctness, or do you have an
actual use case that is affected by this? In the latter case, I would
agree that v:register should account for the yank command. (But I don't
know how easy that would be to implement.)
-- regards, ingo
Then YankRing plugin
(http://www.vim.org/scripts/script.php?script_id=1234) relies upon
v:register to determine:
a) which register to capture changes from
b) which register to update when retrieving the next value (from the
ring) for pasting
Unfortunately, there really is no work around for it either.
I could choose "+yy, or in this case yy. There is no way to distinguish
those commands.
Dave
That text is obsolete; it was changed in changeset b6471224d2af dated 9
February and again in changeset 3c7da93eb7f9 dated 10 May. The current
text is as follows:
> *v:register* *register-variable*
> v:register The name of the register in effect for the current normal mode
> command. If none is supplied it is the default register '"',
> unless 'clipboard' contains "unnamed" or "unnamedplus", then
> it is '*' or '+'.
> Also see |getreg()| and |setreg()|
Note that the text speaks of "the register in effect for the current
normal-mode command". When not in a normal-mode command (as with :echo)
the value is unspecified. A strict interpretation of the above text
implies that the only place where you could actually examine the value
of v:register and get a meaningful result would be in the {rhs} of a
Normal, Visual or Operator-Pending mapping (preferably with the <expr>
modifier). However if the meaning is extended to ex-commands which
accept a register argument it might have a value (inaccessible to the
user) during :put, :delete or :yank, and an accessible value during
execution of a user-command defined with the -register modifier.
Anywhere else than the two above cases (mapping and user-command) I
wouldn't rely on this variable having any meaningful value.
>
> In my understanding, v:register is mainly necessary for custom
> operations that work with registers, not for built-in commands like
> yank. Is your inquiry about theoretical correctness, or do you have an
> actual use case that is affected by this? In the latter case, I would
> agree that v:register should account for the yank command. (But I don't
> know how easy that would be to implement.)
>
> -- regards, ingo
>
Best regards,
Tony.
--
Champagne don't make me lazy.
Cocaine don't drive me crazy.
Ain't nobody's business but my own.
-- Taj Mahal
True. There's no way to differentiate between an explicitly specified
unnamed register (""yy) and Vim defaulting to it (yy). For that, another
variable (e.g. v:register0, like the distinction between v:count and
v:count1) would be needed, or, as previously suggested, v:register
should account for the yank command.
While trying to implement the latter (which should be a matter of just
calling set_reg_var(0) in the special yank case), I've started to doubt
your interpretation of the "unnamedplus" help.
> ... 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.
Looking at the source and based on my own experiments, deletes _and_
yanks will go to register + with "unnamedplus". With
"unnamed,unnamedplus", yanks will _additionally_ go into register *, as
well as to register +. This also makes more sense to me from a usage
point of view than your interpretation.
However, this is at odds with the steps given in your initial message.
I'm currently on vacation and restricted to my wife's Ubuntu laptop, so
I'm not 100% confident about my own findings.
Could you please verify this once more? Maybe this isn't an issue at
all, just "user confused" :-)
-- regards, ingo