On Sun, Jul 09, 2006 at 04:12:49PM +0000, Yakov Lerner wrote:
> On 7/9/06, Matthias-Christian Ott <[EMAIL PROTECTED]> wrote:
> >Yakov Lerner wrote:
> >> This is wrong.
> >> You want "\n", not '\n'.
> >Ok, but the problem still exists.
>
> >vnoremap <silent> <C-W> :call FormatDeclarationSelection ()<CR>
> >
> > let lines = split (@", '\n')
>
> The problem has nothing to do with split().
>
The solution is to add keyword "range" to the function header line:
>
> function FormatDeclarationSelection () range
>
> This makes the mapping to invoke the funcion once, not
> once-per-line. See :help function-range-example
>
> Yakov
Another option is to remove the range before calling the function:
either
vnoremap <silent> <C-W> <Esc>:call FormatDeclarationSelection ()<CR>
or
vnoremap <silent> <C-W> :<C-U>call FormatDeclarationSelection ()<CR>
Remember that, when vim switches from Visual mode to Command-Line mode,
it automatically inserts the range '<,'> .
HTH --Benji Fisher