Unix Text Editors

Unix text editors are quite unlike the word processors found on Windows and Macintosh systems. They do not support WYSIWYG editing, auto-formatting, line-wrapping, multiple fonts, or multiple font sizes. Instead they are oriented toward plain text.

On the plus side, Unix text editors have lots of features, such as auto-indentation and syntax highlighting, that make them idea for writing scripts, programs, and HTML pages.

Text Editors Available on Linux Systems

vi
Non-graphical (terminal-based) editor. Guaranteed to be available on any system. Requires knowledge of arcane keystroke commands. Distinctly unfriendly to novices.

emacs
Window-based editor. Menus make it more friendly to novices, but you still need to know keystroke commands to use many of the advanced functoins. Installed on all Linux distributions and on most other Unix systems.
xemacs
More sophisticated version of emacs, but usually not installed by default. All common commands are available from menus; however the user interface is still confusing at first. Very powerful editor, with built-in syntax checking, Web-browsing, news-reading, manual-page browsing, etc.
pico
Simple terminal-based editor available on most versions of Unix. Uses keystroke commands, but they are listed in logical fashion at bottom of screen.

[X]Emacs Survival Guide

Minimal commands needed to use [x]emacs.

Launch [x]emacs
xemacs &

Open a (new) file from command line
xemacs new_file.txt&

Open a (New) file from within [x]emacs

Save a file that you are editing
^X^S (control-x, control-s)

Save the file that you are editing under another name
^X^W (control-x, control-w)
Prompt will appear at the bottom of the window. Type in the name or path of the file to save as. Hit tab to do command completion.

Quit [x]emacs
^X^W (control-x, control-c)

Cancel current activity
^G (control-G)
This is very useful when [x]emacs is prompting you to do something, and you don't know what it wants you to do.

Cancel all pending activities
^] (control-right bracket)
Try this if ^G doesn't work.

Switch to another buffer
^X-b (control-X, b)
Unlike word processors, [x]emacs uses buffers to hold the contents of a file rather than windows. You can have many files open simultaneously, each in a separate buffer. You can also have several windows open, but each can only display one buffer at a time. ^X-b allows you to switch from one to another.

Get rid of a "frame"
^X-0 (control-X, 0)
[x]emacs will sometimes split a window into multiple panels (which it calls "frames") and display some informational text in one of them. To get rid of the extraneous frame, put the cursor in it (by clicking) and type ^X-0. You can create your own panels by typing ^X-2 (to divide the window horizontally), or ^X-5 (to divide the window vertically). Switch between frames by clicking in the one you want to become current, or by typing ^X-o.

When a file is displayed, these editing commands work:

Backspace
Delete the previous character and back up one.

Left arrow, right arrow
Move the text insertion point (cursor) one character to the left or right.

control-A (^A)
Move the cursor to the beginning of the line. Mnemonic: A is first letter of alphabet

control-E (^E)
Move the cursor to the end of the line. Mnemonic: <E> for the End (^Z was already taken for something else).

control-D (^D)
Delete the character currently under the cursor. D=Delete.

control-K (^K)
Delete the entire line from the cursor to the end. K=Kill. The line isn't actually deleted, but put into a temporary holding place called the "kill buffer".

control-Y (^Y)
Paste the contents of the kill buffer onto the command line starting at the cursor. Y=Yank.

Handy Trick: Saving a Shell Session History

emacs has a built-in shell. When activated it acts just like the terminal shell except that your commands and all command output is captured into a buffer that you can edit and save. To invoke the emacs shell:

  1. Launch [x]emacs
  2. Type alt-x "shell" ("x" with the alt key held down, then the command "shell".
  3. This will open a shell in the current buffer.
  4. When you want to save the contents of the buffer to a file, choose File=>Save As...

<< Previous
Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Thu Oct 9 20:25:58 EDT 2003