Monday, January 23, 2012

Re: V""p vs Vp

Hi Albin!

On So, 22 Jan 2012, Albin Olsson wrote:

> On Sun, Jan 22, 2012 at 7:47 AM, John Beckett <johnb.beckett@gmail.com> wrote:
> > David Fishburn wrote:
> >> I am trying to figure out why I see different behaviour when
> >> performing what I consider identical actions.
> >
> > Strange, I see that too (also with Vim 7.2.18).
> > BTW the first "Shows 1" should be "Shows 2".
> >
> > The issue is as follows: start with two lines:
> >
> >    123
> >    456
> >
> > 1. Press Y on the first line.
> > 2. On the second line, press V then ""p
> >   Result: No visible change (should have changed to "123").
> > 3. Press Y on the first line.
> > 4. On the second line, press V then p
> >   Result: The second line is replaced with "123".
> >
> > After step 2, :echo @" shows 456 so Vim thinks the second line
> > was changed, but it wasn't.
> >
> > The question is, what is ""p doing?
>
> If you replace text, the text replaced will first move to the unnamed
> register, which is the very register you are pasting from. In steps:
>
> 1. Remove the text and place it in the register
> 2. Paste from the register

No that is not like it works. Exactly for the reason, that
pasting wouldn't be possible anymore. And the help clearly
states how it works:

,----[ :h v_p ]-
| When using a put command like |p| or |P| in Visual mode, Vim
| will try to replace the selected text with the contents of
| the register. Whether this works well depends on the type
| of selection and the type of the text in the register.
| With blockwise selection it also depends on the size of
| the block and whether the corners are on an existing
| character. (Implementation detail: it actually works by
| first putting the register after the selection and then
| deleting the selection.)
`----

This patch fixes it:
diff --git a/src/normal.c b/src/normal.c
--- a/src/normal.c
+++ b/src/normal.c
@@ -9329,7 +9329,7 @@
# ifdef FEAT_CLIPBOARD
adjust_clip_reg(&regname);
# endif
- if (regname == 0 || VIM_ISDIGIT(regname)
+ if (regname == 0 || VIM_ISDIGIT(regname) || regname == '"'
# ifdef FEAT_CLIPBOARD
|| (clip_unnamed && (regname == '*' || regname == '+'))
# endif


regards,
Christian
--
Gott bevorzugt gewöhnliche Menschen. Darum schuf er so viele von
ihnen.
-- Abraham Lincoln

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