[Gllug] vi vs emacs (repeat)
Nix
nix at esperi.org.uk
Mon Mar 7 17:52:40 UTC 2005
On Fri, 4 Mar 2005, Craig Millar said:
> vi vs emacs - i have finally decided to familiarise myself beyond the usual
> navigational commands with one or the other. for someone who came from a gui
> background and uses kde extensively i've never had cause or motivation to do
> so before but now that i've taken up mutt as my mail client, utterly
> disillusioned with the mozilla suite and several others as mail clients, it's
> long overdue.
(Disclaimer: I'm an Emacs-head, so the Emacs information here is
necessarily a lot more detailed than the vi information. Nonetheless,
I'm trying not to be unfair to either editor, even though vi users *are*
necessarily mindless malodorous spawn of Satan who will burn for a
billion years in the `fires-of-hell' package, while Emacs users are
naturally wise attractive super fun wild crazy and deeply modest guys
and gals. So there.)
There's one good reason why this whole issue arouses so much religious
passion: the editors are philosophical opposites, and attract opposite
kinds of people: both are children of the 1970s, but vi came from the
minimalist Berkeley school, steeped in Unix, C, and quick hacks that
just work dammit, and Emacs from the maximalist MIT school, steeped in
massive timesharing systems, Lisp, and theoretical elegance.
vi is the quintessential `Unix-like editor'; it Just Gets The Job Done
and does absolutely nothing but edit text in the most minimal way
possible, and has a baroque and rebarbative user interface entirely
because it was hacked up in two weeks and then everyone got used to the
result. People who are attracted to Unix because of its minimalism and
componentish architecture (the Unix toolset and so on) are likely to be
attracted to vi for the same reasons: unsurprisingly, because vi and
Unix came from the same people. (perl users may well also like vi.)
The editor is strongly modal: you're typing text or doing other things,
never both at once, and you need to explicitly switch (ESC goes one way,
`i' and `a' and a myriad of other keystrokes go the other way).
Traditionally you couldn't even move the cursor or delete text in
the text entry mode.
You tend to run lots of `vi's, one per file, and traditionally you'd do
things like indentation by running external commands.
Comparatively recently, the `vim' reimplementation has popped up, which
supports many more features inside the editor, syntax highlighting,
autoindentation, a sort of on-line help and so on.
vi can probably do lots of other things, but I'm afraid that its decided
irregularity and the lack of an elegant underlying framework has
generally stopped me learning anything other than the simplest things
about it: the rest drops out of my head: I can't learn things that don't
base themselves on simple underlying principles well, and vi doesn't
seem to bother with principles *anywhere*. (I'd call this a personal
failing, but it's really a sign of the underlying satanic origin of vi.)
Emacs, one of the GNU Project's flagship programs, is the diametric
opposite of vi. It's an attempt by a community forced onto Unix by the
demise of other machines to (in effect) reimplement the old Lisp Machine
on Unix.[1] The result is an elegant core (a Lisp interpreter with a
text editor implemented in it), totally flexible and reconfigurable at
runtime, with an obscene amount of documentation and more features than
you'll *ever* learn[2] and a flourishing community of people writing
add-ons to add yet *more* features.
One confusing thing is that, like vi, Emacs predates current editor
ideas, so all its terminology is different. It has a persistent `region'
rather than the `selection', `point' rather than `the cursor', `buffers'
rather than `files', `frames' rather than `windows'... this is a
particular annoyance to new users because all the docs use Emacs's
terminology. (Note that most of the `flashy new ideas' in current
editors were being done better by Emacs decades before those editors
thought of them!)
However, it's quite non-Unixlike: it's a single huge program which
prefers to talk only to things inside itself, with a large startup cost,
and the flourishing community of add-on writers leads to a lot of
add-ons which do the same thing in slightly different ways and a lot
of inconsistency outside of the fundamental core.
Getting the full power out of Emacs really requires extending it (even
if in small ways), which requires learning Lisp, which is a large wrench
for non-programmers and a considerable one even for people who've never
seen functional languages before (but still I'd recommend it: Lisp is a
*lovely* language which will really open your eyes and change the way
you think about computing, even Emacs's rather old and ugly Lisp
variant).
(Probably, by now, more people have been introduced to Lisp by Emacs
than by any other single thing.)
This config file feeds on itself. You tend to accumulate a vast set of
configuration files over years and act lost if you don't have
them. (Mine is automatically kept updaetd on the web, under my homepage:
<http://www.esperi.demon.co.uk/nix/>).
You tend to run one Emacs, leave it up for *weeks* and do almost
*everything* inside it, quitting only if you do something seriously
silly and mangle the editor's state or are forced to log out. Mine keeps
track of my timesheets, tracks my to-do lists, watches for RSI, runs my
shells (it has multiple competing terminal emulators), reads my mail,
reads my news, does a certain amount of web browsing, reindents my code,
compiles it, debugs it, psychoanalyzes me, makes my coffee and steals
my job.
The editor is strongly modal, but in quite a different way than is vi:
each file you work on is `in a mode' (C++, shell scripting, terminal
emulation, newsreading, whatever) and the mode can affect indentation,
key bindings (*all* the key bindings), and, well, virtually anything
about the behaviour of the editor when you're editing that file.
I mentioned the documentation. Emacs has the following separate docs:
- a FAQ.
- a new users' tutorial which people starting Emacs for the first time
are encouraged to use.
- a user's reference.
- a Lisp new user's guide (`learning Lisp for Emacs users', roughly).
- a Lisp reference (editor customization).
- hyperlinked documentation for *every* keystroke and *every* Lisp
function in the editor (and there are thousands of them), in
multiple directions.
Last time I checked that was over 3500 pages (should you typeset them
and print them out).
People who like elegant systems and functional languages tend to
gravitate to Emacs; a lot of Python users, for instance, and a lot of
people developing GNU software :)
Odd, really, because while Emacs's core is elegant it's accumulated so
much cruft over the years that it's now a classic example of the `big
ball of mud' design pattern.
Crude polls (such as emacs versus vi paintball matches) tend to indicate
that vi users outnumber Emacs users by about two to one in the Unix
community. (However, Emacs users exist outside the Unix community,
too: it's never been a purely Unix editor.)
One obscure historical note: vi is a historical dead-end; the original,
ancient, pre-GNU Emacs (via Borland's Brief and WordStar) is in some
sense the historical father of essentially *every* other full-screen
display editor and word processor in existence. (All of them foolishly
discarded the Lisp-interpreter-core idea which makes Emacs actually
worth using...)
[1] Yes, I know Emacs predates the Lisp Machine and I know it runs on a
lot of other platforms. I'm simplifying. :)
[2] I learn new (X)Emacs features on a daily basis, and I've been using
it for ten years now
--
> ...Hires Root Beer...
What we need these days is a stable, fast, anti-aliased root beer
with dynamic shading. Not that you can let just anybody have root.
--- John M. Ford
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list