Prev - Index - Next


Who wants to remember that escape-x-alt-control-left shift-b puts you into super-edit-debug-compile mode?

(Discussion in comp.os.linux.misc on the intuitiveness of commands, especially Emacs)

Irrespective of your choice of programming language, you will need an editor!

The classic Unix text editors are Emacs and VI, which offer very different approaches to text editing and have caused one of the more fanatical religious wars of the 20th Century.

Key features to look for in any programmer's text editor include:


The original Emacs was written by Richard Stallman, and has seen a number of different implementations, both as free and commercial software. The most well-known of these are the split releases of GNU and X-Emacs.

Emacs supports (and usually pioneered) almost any programming feature that a text editor could use, and also offers a wide range of support tools, including a RCS/CVS interface, patch/comp/diff/merge support, Postscript "pretty" printing, mail and news clients, a web browser, shell support with piping and command completion, FTP support for the editing of remote files, a spreadsheet and a wide variety of games.

Emacs comes close to an integrated development environment, with support for a vast selection of programming languages, and intelligent interfaces to make and gdb. If a particular aspect of the editor does not suit your needs, or is missing, Emacs is readily extended through the inbuilt programming language called elisp (a Lisp variant).

An example of elisp is this snippet from my ~/.emacs initialisation file, which adds two new keystrokes to my C-mode (for programming in C). Control-M now does a new-line and then moves the line so that it is correctly indented, while Control-C/Control-C saves the current file and then compiles the program. Finally, it ensures that font locking (aka syntax highlighting is turned on.

;; save and compile current C code buffer
(defun my-save-and-compile ()
  "Save current buffer and issue compile."
  (interactive "")
  (save-buffer 0)
  (compile "make -k"))

;; set up the hooks for C-mode
(add-hook 'c-mode-hook
	  '(lambda ()
	     (define-key c-mode-map "\C-m" 'newline-and-indent)
	     (define-key c-mode-map "\C-c\C-c" 'my-save-and-compile)))

(add-hook 'c-mode-hook 'turn-on-font-lock)

The screenshot below shows a simple C program being edited. The two windows show the source file and the output from the make command, which has failed due to a missing variable that has been called in line 15. The cursor has been placed at the error location in the source file.

The buggy code and the correct code are listed here for interest's sake.

Emacs demo image

Emacs comes in a number of implementations. Of the full-scale versions, GNU Emacs and XEmacs are the most well-known, while there are a large number of small-scale implementations, such as JOVE, JED and MicroEmacs.

If you prefer the Emacs style of editing or the keystrokes, but do not want the extensive memory (or disk) requirements of GNU Emacs, then a smaller-scale implementation such as JED is ideal.


VI was the first visual editor, as opposed to the earlier line mode editors, such as ex (and MS-DOS edlin). It is small, and is a standard program on almost every Unix variant. Even if you prefer to use another editor, it is worth knowing VI for emergencies!

Unlike EMACS (and many other editors), VI focuses on the task of text editing and normally relies on external programs for other tasks, such as text formatting and spell checking.

VI is a modal editor, meaning that there are different modes of operation controlling the actions of the editor. The two important modes are:

Modern versions of VI, such as VIM, VILE and elvis offer most (if not all) of the features required in a modern text editor while maintaining the VI paradigm of dual mode.

Other editors

If neither Emacs or VI is to your liking, there are a number of other free and commercial text editors. Some of the more widely used include NEdit, SlickEdit and Crisp.

There is an exhaustive list of Linux text editors at SAL.


GNU Emacs screenshot NEDIT screenshot VIM screenshot
GNU Emacs with C code NEdit with C++ code VIM with Python code

Prev - Index - Next