anna wrote: > :function! Foo() > :echo "foo" > :endfunction > :nmap x :call Foo()<CR> > > If I input "x" or "2x" in normal mode, it behaves as > expected, echoing "foo". However, if input "3x" or greater > range, then it throws me error E16:Invalid range".
I'll try another approach at the explanation. You will notice that "2x" moves the cursor down one line. Vim executes ':call Foo()' twice: once on the current line, then a second time on the next line down. When you used "3x" Vim tried to call the function three times: on the current line and each of the next two. But it ran into end-of-file and so gave the error message. If you wanted to handle the count yourself, you could do this: :function! MultiFoo() range : for i in range(v:count1) : echo "foo" : endfor :endfunction :nmap x :<C-U>call MultiFoo()<CR> John --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
