Unnamed register only contains the last deleted text when appending deleted text to a register

64 views
Skip to first unread message

Wolfgang Jeltsch

unread,
Apr 10, 2017, 10:39:20 AM4/10/17
to vim...@vim.org
Hi!

The Vim documentation says the following under “quote_quote” about the
unnamed register ("):

>
> Vim fills this register with text deleted with the “d”, “c”, “s”, “x”
> commands or copied with the yank “y” command, regardless of whether
> or not a specific register was used (e.g. "xdd). This is like the
> unnamed register is pointing to the last used register. Thus when
> appending using an uppercase register name, the unnamed register
> contains the same text as the named register.
However, the part with uppercase register names does not work for me
when deleting. I only get the last deleted text into the unnamed
register. For example, when I enter "add and then "Add, register a
contains both deleted lines, but the unnamed register only contains the
last one, although it should contain the same text as register a.
However, things work as expected with the yank (y) command.

I asked on StackExchange why this is and several people told me that
this seemed like a bug to them. So is this a bug? If not, why is Vim
behaving like this?

All the best,
Wolfgang

Ben Fritz

unread,
Apr 10, 2017, 10:46:38 AM4/10/17
to vim_dev, vim...@vim.org, wolfg...@jeltsch.info
I can't reproduce this in 8.0.427 64-bit gvim on Windows. What version of Vim are you using? Does it do the same thing without your configuration loaded, e.g. when launching with "gvim -N -u NONE -i NONE"?

Wolfgang Jeltsch

unread,
Apr 10, 2017, 11:26:27 AM4/10/17
to vim...@googlegroups.com
Yes, the behavior is the same with “gvim -N -u NONE -i NONE”. I use
Vim 7.4 including patches 1–1689 on Ubuntu 16.04 LTS.

All the best,
Wolfgang

Ben Fritz

unread,
Apr 10, 2017, 11:32:19 AM4/10/17
to vim_dev, wolfg...@jeltsch.info
On Monday, April 10, 2017 at 10:26:27 AM UTC-5, Wolfgang Jeltsch wrote:
> >
> > I can't reproduce this in 8.0.427 64-bit gvim on Windows. What version
> > of Vim are you using? Does it do the same thing without your
> > configuration loaded, e.g. when launching with "gvim -N -u NONE -i
> > NONE"?
>
> Yes, the behavior is the same with “gvim -N -u NONE -i NONE”. I use
> Vim 7.4 including patches 1–1689 on Ubuntu 16.04 LTS.
>

My mistake. I CAN reproduce the issue, I tested the wrong thing. Sorry about that! I also see that pasting from the unnamed register, after a series of deletes into an UPPERCASE named register, pastes only the last delete instead of the entire named register.

I agree it looks like a bug, and it looks like it's been around for a while now!

At least, the help text doesn't match the actual behavior. I think the behavior described in the help text would be more useful than the actual behavior.

Wolfgang Jeltsch

unread,
Apr 10, 2017, 4:40:21 PM4/10/17
to vim...@googlegroups.com
Am Montag, den 10.04.2017, 08:32 -0700 schrieb Ben Fritz:
> My mistake. I CAN reproduce the issue, I tested the wrong thing. Sorry
> about that! I also see that pasting from the unnamed register, after a
> series of deletes into an UPPERCASE named register, pastes only the
> last delete instead of the entire named register.
>
> I agree it looks like a bug, and it looks like it's been around for a
> while now!
>
> At least, the help text doesn't match the actual behavior. I think the
> behavior described in the help text would be more useful than the
> actual behavior.

I also think that the behavior described in the help text would be more
useful.

Should I file a bug report somewhere?

All the best,
Wolfgang

Ben Fritz

unread,
Apr 10, 2017, 4:47:08 PM4/10/17
to vim_dev, wolfg...@jeltsch.info

Posting to this list should be enough.

Bram Moolenaar

unread,
Apr 11, 2017, 4:37:21 PM4/11/17
to vim...@googlegroups.com, Ben Fritz, wolfg...@jeltsch.info
I have added an item in the todo list:

Unnamed register only contains the last deleted text when appending deleted
text to a register. (Wolfgang Jeltsch, reproduced by Ben Fritz, 2017 Apr 10)

--
Luxury. We used to have to get out of the lake at three o'clock in the
morning, clean the lake, eat a handful of hot gravel, go to work at the
mill every day for tuppence a month, come home, and Dad would beat us
around the head and neck with a broken bottle, if we were LUCKY!

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Christian Brabandt

unread,
Jun 27, 2017, 6:39:14 AM6/27/17
to Bram Moolenaar, vim...@googlegroups.com, Ben Fritz, wolfg...@jeltsch.info

On Di, 11 Apr 2017, Bram Moolenaar wrote:
> Unnamed register only contains the last deleted text when appending deleted
> text to a register. (Wolfgang Jeltsch, reproduced by Ben Fritz, 2017 Apr 10)

Here is a patch. The problem is, that in op_delete() we are
unconditionally resetting y_previous to point to register 1. This
shouldn't happen, if we are appending to an existing register.

I added a test, so that the behaviour can be verified.

Best,
Christian
--
Wir haben nicht mehr Recht, Glück zu empfangen, ohne es zu schaffen,
als Reichtum zu genießen, ohne ihn zu produzieren.
-- George Bernard Shaw
0001-fix-deleting-using-upper-case-reg-correctly-stored-i.patch

Bram Moolenaar

unread,
Jun 27, 2017, 9:39:43 AM6/27/17
to vim...@googlegroups.com, Christian Brabandt, Ben Fritz, wolfg...@jeltsch.info

Christian Brabandt wrote:

> On Di, 11 Apr 2017, Bram Moolenaar wrote:
> > Unnamed register only contains the last deleted text when appending deleted
> > text to a register. (Wolfgang Jeltsch, reproduced by Ben Fritz, 2017 Apr 10)
>
> Here is a patch. The problem is, that in op_delete() we are
> unconditionally resetting y_previous to point to register 1. This
> shouldn't happen, if we are appending to an existing register.
>
> I added a test, so that the behaviour can be verified.

Thanks.

I'm slightly worried that other people will now complain...
Well, we'll see.

--
From "know your smileys":
(:-# Said something he shouldn't have
Reply all
Reply to author
Forward
0 new messages