Monday, January 23, 2012

Re: V""p vs Vp

Christian Brabandt wrote:

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

Thanks, I'll include it.

--
An easy way to determine if you have enough teamwork to be doomed is simply to
measure how long it takes from the time you decide to go to lunch together
until the time you actually eat.
(Scott Adams - The Dilbert principle)

/// Bram Moolenaar -- Bram@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 ///

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