On Tue, Jul 11, 2006 at 01:52:40PM -0500, Tim Chase wrote: [snip] > > Well, after hacking at it on and off for the last day or two, > trying various ideas, this is one of my uglier hacks and abuses > of vim's conventions. > > function! IncRoman(initial, howmuch) > " do your own IncRoman stuff here...this > " just a generic increment > try > let l:result = a:initial + a:howmuch > catch > let l:result = a:howmuch > endtry > return l:result > endfunction > > :noremap <c-a> :<home><right><right><right><right><c-u>let > howmuch=<end>+1<cr>ciw<c-r>=IncRoman(@-,howmuch)<cr><esc> > > This one-liner mapping (in case mailers on either end of things > ended up breaking that mapping line) seems to work correctly on > various values that I threw at it. If you try to increment a > non-number, it will replace it with the increment quantity, which > seemed reasonable to me. If you don't like the behavior, you can > change the "catch" clause to return what you prefer (either the > initial contents, or an empty string would be other good candidates). > > It should even be swappable if you have a companion DecRoman > function with the same sort of call-signature. > > It's a horrible abuse of the fact that vim, when you start typing > a count and press the colon, defaults to the range ".,.+x" where > "x" is one less than the count given. But it works :)
So you delete everything but the "x" and then continue the command line after that? Yes, that is a hack. Why not just use <C-U> in the mapping (after the : ) to clear the command line, then use v:count or v:count1 instead of the second argument? HTH --Benji Fisher