Reply to message «RE: [BUG?] Modifications of visual selection are not remembered during mapping execution», sent 21:37:58 07 July 2011, Thursday by MacDonald, Stuart:
I did not want anything here: while testing an answer to one question on
stackoverflow I noticed strange behavior and went to vim-dev to ask whether it
is a bug (that is why I wrote [BUG?], not [BUG]). Thanks to Bram, he explained
what is going on here.
I personally will never write such mapping: using :normal to reenter visual
mode
after you escaped from it using the colon looks like some black magic to me; I
normally use <expr> mappings or feedkeys() here.
Original message:
> From: On Behalf Of ZyX
>
> > Subject: Re: [BUG?] Modifications of visual selection are not remembered
> > during mapping execution
> >
> > It is already normal vimscript: equivalent to
> >
> > vim -N -u NONE -S <(<<EOF
> > call setline(".", range(1000))
> > function! EV()
> >
> > echom 0
> > normal! gv30j
> >
> > endfunction
> > vnoremap e :call EV()<CR>
> > call feedkeys("V4je")
> > EOF)
>
> This can be simplified to
> vim -N -u NONE -S <(<<EOF
> call setline(".", range(1000))
> call feedkeys("V4j:normal gv30j\<CR>")
> EOF)
>
> and still exhibit the behaviour. (The echom 0's are missing of course.)
> It doesn't look like a problem with mappings.
>
> The following exhibits the same behaviour
> vim -N -u NONE -S <(<<EOF
> call setline(".", range(1000))
> call feedkeys("V4j\<Esc>")
> call feedkeys(":1,5:normal gv30j\<CR>")
> EOF)
>
> > > > You will see that while function EV was called 5 times (five
> > > > zeroes in :messages), cursor is on the line containing number 33,
> > > > while it is expected to be on line with number 5*30=150.
>
> It looks like what you want is something like
> vim -N -u NONE
>
> :call setline(".", range(1000))
>
> V30jgv30jgv30jgv30jgv30j
>
> (sorry, couldn't figure out how to wedge a [count] in there) but that
> only works because when gv is typed there is no previous visual
> selection to swap with so it fails to do anything. Equivilantly
> vim -N -u NONE
>
> :call setline(".", range(1000))
>
> V30j30j30j30j30j
>
> Perhaps you wanted a [count] instead of a [range]?
>
> ...Stu
signature.asc
Description: This is a digitally signed message part.
