vim function

Alan Young alansyoungiii at
Fri Aug 11 10:40:49 MDT 2006

Paul Seamons wrote:
>> blah blah IFcondition<ESC><DOWN>a<TAB>write true handler (6 non-code
> keystrokes assuming you are in already in insert mode and want to stay there 
> after)

Actually, 8 keystrokes because it would be <SHIFT>i<SHIFT>f.

> Hi Alan.

Hi.  Howzit goin'? :>

> In many other editors, you would type the following (which costs 3 more key 
> strokes (actually, many editors wouldn't need the <TAB> so it would only be 2 
> more):
> blah blah if<SPC>(condition)<SPC>{<CR><TAB>write true handler<CR>} (9 non-code 
> keystrokes - 8 if the editor supports autoindentation)

That would be

if<SPC><SHIFT>9condition<SHIFT>0<SPC><SHIFT>[<CR>write true

(I have smartindent turned on, so the tab isn't necessary this way and
we'll ignore the whitespace I usually put into the condition ()'s).

This gives us 12 key presses (4 of which are shift key combos).

> a) it isn't all that hard to type


> b) it doesn't need the macro

True ... sort of.

> c) it puts you right after the } in case you want to start right into a 
> following else or elsif (else if for most)


> to get there with that macro you'd have to type the following:
> blah blah IFcondition<ESC><DOWN>a<TAB>write true handler<ESC><DOWN>a (8 
> non-code keystrokes)

It just occurred to me that if I got rid of the blank line between the
curly brackets in the macro, I could do this:

blah blah IFcondition<ESC>owrite true handler<ESC><DOWN>

which would be 6 keystrokes (including <SHIFT>I<SHIFT>F) which would cut
the keystrokes by half.

That's just the if construct, the for and while constructs would have a
few characters more.

In any case I'm just trying to be lazy and make VIm do as much as possible.

> Some things make coding easier, some are fun, some are wow.  It is up to the 
> developer to decide which categories each new thing falls into.

I don't know yet if this will make it easier for me ... I'm planning on
finding out as I go.

> I'm not meaning to be rain on somebody's parade, just a glance from a few 
> steps back.

:] Didn't take it that way.  Thanks for the insights.


More information about the PLUG mailing list