Editor macro languages

Adam V. Reed adam at mtund.UUCP
Mon Oct 13 13:58:50 AEST 1986


Kenneth Ng:
> Now for a little soap box time.  It seems to me that one of the
> most powerful features of a text editor is the ability to write
> custom programs with a language the editor can understand.  The
> three editors mentioned above have such features.  Therefore
> practically any needed function can be added easily.  This is the
> one feature I find so lacking in VI(1).  The macro facility kinda
> has this, but I haven't seen the functionality of a real programming
> language in this editor.

Not unless you consider C, and the Korn shell, and every language
available under Unix [tm], something other than "real" programming
languages. The "!" command (which can be included in map micros) lets you
filter any subset of a file through any pipeline. For example, the vi
command to alphabetize lines 23 through 77 is ":23,77!sort^M". There is
nothing to stop you from writing a custom C program to use in vi macros,
but usually there already are Unix tools around to do the job. Note that
the output of a filter can be placed in a buffer and executed (there are
spelling correction macros that use this capability).

Being able to use the shell, or a programming language of one's
choice, instead of having to learn a custom editor macro language,
is one of the tremendous advantages of working under Unix. I once
implemented a syntax-directed editor as a set of vi macros filtering
text through a few shell scripts and one C program, in a quarter of the
time it would have taken to write an SDE from scratch. When a novice
complains that some part of Unix is not powerful enough, the cure
is RTFM.
					Adam Reed



More information about the Comp.unix.wizards mailing list