On Fri, October 16, 2009 9:16 am, Dewr wrote: > keymapped functions repeat when it called while vim is selecting a text > block. > > I have tested with this code. > function foobar() > echo "foobar!" > endfunction > map <F5> :call foobar()<CR> > > I could avoid this by adding ^[ (=esc) at the head of key-mapping command.
Well, if you don't need the mapping in visual/select mode, then don't define it ;) e.g. use nmap <F5> :call foobar()<CR> I believe the reason is, that the function is called each time for the range, defined by the selection (marks '<,'> actually). So if you need your function in visual mode, to be called only once, define the function to take care of the range itself by adding the range keyword (see :h function-range-example). Alternatively use <CTRL-U> to get rid of the markers, when defining your map. :map <F5> <C-U>:call foobar()<CR> This ensures, that your function is only called once, but then it doesn't know on which range it was called. regards, Christian -- :wq --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
