October 17, 2001, 5:17 PM — It took a little longer to prepare for this
month's column:
Nomex suit? ...Check!
Kevlar vest? ...Check!
Elbow pads? ...Check!
Helmet? ...Check!
Ready? ...Ready!
OK. Here is the entire column, in a nutshell:
Emacs rules.
vi drools.
Right about now, all the Emacs users are surfing off to other parts of
the magazine, wondering why I'm restating the obvious. All the vi users
are angrily sending e-mail that reads something like this:
You are a blithering idiot! Emacs is the worst editor ever
invented! I learned vi and I've never needed anything else!
:wq!
^[kdd:w!q!ZZ
^C^D.exit
quit
logout
The rest of you are probably wondering what on Earth I'm talking about.
Back to basics
When developing software, the most important tool at your disposal is
your text editor. It must be robust, extensible, easily learned, and
productive. You will probably spend more time using your text editor
than any other tool. It should fit like a glove and be as comfortable
as an old shoe.
Within the world of Unix software development, there are two principal
choices for editors: Emacs and vi. Invariably, the people who choose
Emacs loathe vi, and those who choose vi are appalled by Emacs. In case
you hadn't figured it out by now, I'm in the former camp. In spite of
my obvious bias, I'll still try to give a brief overview of each tool,
expanding on the virtues and drawbacks of each.
Emacs: the tool of tools
Emacs is a freely available editor originally written by Richard
Stallman and since enhanced by thousands of enterprising contributors.
It is distributed by the Free Software Foundation and is available in
both source code and precompiled forms. (You can ftp a copy from the
/pub/gnu directory at prep.ai.mit.edu or one of numerous mirror ftp
sites. ) It supports both
character-based and X Window environments and runs under a wide variety
of operating systems, including Unix, DOS, and Windows.
Emacs has been written by programmers for programmers. Its single best
feature is that it is infinitely extensible by means of a built-in LISP
interpreter. Almost every command in Emacs is actually a tiny little
LISP program that acts upon your text files. To extend Emacs, you
simply modify the existing programs or add a few of your own.
Emacs is known as a "modeless" editor, meaning that it is always ready to
both accept text as input and act upon that text via user commands.
You never switch between "command" and "input" modes in Emacs.
In Emacs, modes exist for just about
every conceivable programming language
-- even languages like HTML.
New users are sometimes confused by the fact that Emacs does have
various operating modes that determine how text in a particular buffer
will be handled. For example, Emacs has a "C" mode that understands how
C programs are formatted. As you type your source code, Emacs
automatically indents and formats your code. In the X version, it will
even render function names and other language elements in various colors
and fonts to make them more readable. Other modes exist for just about
every conceivable programming language, even languages like HTML.
There are even some word processing modes that indent, flow, wrap, and
format your text automatically.
Emacs was popular well before window systems came into vogue.
Programmers who were editing code disliked having to exit the editor to
perform other tasks like reading mail or running the compiler. As a
result, they added features to Emacs that let you read your mail, run
the compiler, invoke the shell, and even browse the web all without
leaving the comfy world of Emacs. Since Emacs sports a complete
programming environment, enhancements like these can be made relatively
easily.
Emacs deals with text as collections of lines within a buffer. Usually,
a buffer corresponds to a single text file. You can have any number of
buffers loaded into Emacs, making it easy to edit programs broken into
many separate modules. Emacs lets you split the screen any number of
ways so you can view multiple files simultaneously, and it's easy to
move text between buffers.













