On 4/11/06, Yakov Lerner <[EMAIL PROTECTED]> wrote:
> On 4/11/06, Anatoli Sakhnik <[EMAIL PROTECTED]> wrote:
> > Hello!
> > Can anyone tell me what's wrong in the following function. I select
> > something, press \/, enter _graph on the prompt and get another prompt
> > immediately...
> >
> > function! VisualRangeSearch(flags)
> >     let pat = input("'<,'>/")
> >     let s = '\%V'.pat
> >     call search(s, a:flags)
> > endf
> >
> > vnoremap <Leader>/ :call VisualRangeSearch('')
> > vnoremap <Leader>? :call VisualRangeSearch('b')
>
> Something strange is going on here.
> I simplified the testcase to 1 liner:
>
>     vnoremap \\ :call input(line('.').col('.').'>>>')<cr>
>
> If you visual-select multiple lines and press \\,
> you'll see that input() is called multiple times, once
> for each selected line. Strange.

Anatoli, I got it. The lhs is called N times (once for each selected line)
because of :'<,'> range automatically inserted
after ':'.

The solution is to reset visual selection before : using <esc>

      vnoremap \\ <esc>:call Foo()

, and then inside the function, to restore the visual area using
   normal gv

Yakov

Reply via email to