[comp.editors] Loops in VI macros?

s887212@minyos.xx.rmit.oz (Stephen Riehm [Romulis]) (10/07/90)

is it possible to create a macro useing vi's map and  map! functions that
will loop until some condition has become true? for exapmle
I use the following map to format my C code (rather than putting up with
the tabs that cb seems to like to use). It works ok, but if I want to do a
whole file I have to left shift the entire file.. then repeatedly use my
macro until I get to the bottom of the file.
Also this could be used as a nice temporary fix to the problem of the ~
(convert lower to upper case and vice versa) being only a single stroke
command.

-------
# 3 is a 'Civilised' indent width
:set sw=3
#map to put some sort of organisation into C code
:map @ /{^M>%<<^M^G
#note that ^ indicates ctrl character.
------

thanx in advance
============================================================================
Romulis [Stephen Riehm]	            Royal Melbourne Institute of Technology,
					       (124 Latrobe St., Melbourne.)
s887212@minyos.xx.rmit.oz.au					   Australia.

@>---`--,--( Still Stuck on the wrong side of the deep pink sea )--.--'---<@
======================< Insert Usual Disclaimer >===========================

steinbac@hpl-opus.HP.COM (Gunter Steinbach) (10/08/90)

You can loop by using two macros that keep calling each other.

The stop criterion can be an "error" such as trying to go left past
the end of line, not finding another occurrance of a string (maybe with
"nowrapscan" set), etc.  I've used it, but very rarely because it's
dangerous.  If you come up with some useful stuff, please publish it
here.

	 Guenter Steinbach		gunter_steinbach@hplabs.hp.com