[comp.editors] Altering indentation of C code in vi

gwc@root.co.uk (Geoff Clare) (06/18/91)

[I changed the subject line, as "vi and emacs" doesn't seem appropriate
any more].

les@chinet.chi.il.us (Leslie Mikesell) writes:

>... what do you do when you
>add or delete a loop surrounding existing code and want the indentation
>fixed?.   I usually just pipe through cb.

Place the cursor on the opening { or closing } of the block and use >%
to increase indentation (by the current shiftwidth setting) or <% to
decrease it.
-- 
Geoff Clare <gwc@root.co.uk>  (Dumb American mailers: ...!uunet!root.co.uk!gwc)
UniSoft Limited, London, England.   Tel: +44 71 729 3773   Fax: +44 71 729 3273

les@chinet.chi.il.us (Leslie Mikesell) (06/20/91)

In article <2744@root44.co.uk> gwc@root.co.uk (Geoff Clare) writes:
>[I changed the subject line, as "vi and emacs" doesn't seem appropriate
>any more].

Actually, lots of good things come out of the vi vs. emacs discussions
once they get down to the nitty-gritty.

>>... what do you do when you
>>add or delete a loop surrounding existing code and want the indentation
>>fixed?.   I usually just pipe through cb.

>Place the cursor on the opening { or closing } of the block and use >%
>to increase indentation (by the current shiftwidth setting) or <% to
>decrease it.

Works great, thanks!  You do have to remember to shift left *before*
deleting the braces and to put your new outside loop code and braces
one shiftwidth to the left because the right shift will take those
lines along with the inner code.

I'll probably continue to use cb for larger changes, though, because
it will do many levels at once and I can tell at a glance afterwards
if there are mismatched braces anywhere.

Les Mikesell
  les@chinet.chi.il.us