vi vs. Emacs

By Chuck Musciano, Unix Insider |  Development Add a new comment

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.

    Add a comment

    Post a comment using one of these accounts
    Or join now
    At least 6 characters

    Note: Comment will appear soon after you have activated your account.
    Obscene/spam comments will be removed and accounts suspended.
    The information you submit is subject to our Privacy Policy and Terms of Service.

    ITworld LIVE

    DevelopmentWhite Papers & Webcasts

    White Paper

    HP NonStop SQL Fundamentals whitepaper

    This whitepaper offers a detailed look into the fundamentals of HP NonStop SQL solutions. See how this system delivers unprecedented levels of application availability with fail-safe data integrity and meets the needs of enterprises with large-scale business critical applications.

    White Paper

    Nebraska Medical Center case study

    See how the Nebraska Medical Center implemented a SQL solution to make information more readily available to streamline operations, improve patient care and facilitate medical research with an enterprise solution running on HP NonStop servers.

    White Paper

    Concepts of NonStop SQL/MX

    For DBAs and developers who are familiar with Oracle solutions and want to learn about NonStop SQL/MX, this whitepaper provides an overview of the similarities and differences between the two products-with a specific focus on implementation.

    White Paper

    6 Things Your CIO Needs to Know About Requirements

    If your organization is not predictably successful on technology projects, there is likely an issue in requirements. CIOs must take action and own requirements maturity improvement. There are 6 main things a CIO must know about requirements.

    Webcast On Demand

    User Experience Monitoring

    In this webinar, you will learn hints & tips for improving end-user response times from Forrester Research analyst, Jean-Pierre Garbani.

    Sponsor: Nimsoft

    See more White Papers | Webcasts

    Ask a question

    Ask a Question