An Introduction to EMACS

Introduction – Emacs is a powerful, extensible text editor. Emacs originally was an acronym for Editor MACroS . The first Emacs was a set of macros written in 1976 at MIT by Richard M Stallman. Over the years EMACS has become a standard editor used by programmers worldwide.

There are several varieties of EMACS, by typing emacs at the command prompt, you are throw into one of two modes:

  • If you are in an ssh client or are not running X Windows, you will be thrown into a shell or terminal based mode. For many new users this is particularly difficult mode to master, there are no toolbars, and all commands are given via keyboard. Do not think that this is a useless mode, as sometimes the only connection that you may have to a machine is not local.
  • If you launch EMACS locally, it will look pretty much the same, but with some added features for X Windows. There is a toolbar across the top of the window, from which many common tasks can be accessed. You may wish to type emacs& (note the &), as this will free up the shell for other tasks (such as compiling).

There is also a version of EMACS called XEMACS. This version that has many enhancements specifically for X Windows and should be launched locally. There is a graphical toolbar (like MS Word etc..) for basic options as well as a text driven toolbar for other options. To invoke XEMACS just type xemacs, again if you do not want to tie up the shell use an & (xemacs&).

Configuration – use of .emacs file

When emacs (or xemacs) begins, it looks for and reads a file named .emacs in your home directory to obtain configuration information. Save this .emacs file (note the leading "dot") in your UNIX home directory to get the following features (you will need to restart EMACS to invoke these options):

  • Automatic formatting – in accordance with coding style standards of many CMSC classes – (ALWAYS check with your instructor as to specific standards)
  • A working backspace key – backspace will now delete to the left of the cursor instead of invoking "help".
  • A more logical help key – It remaps CTL-X? to be the new "help" key.

Creating & Opening Files

  • To create a file, type the name of the file that you wish to create after the emacs command. Ex: emacs foo.c & or xemacs foo.c & (& optional).
  • To open a file, type the name after the command, just as above.


EMACS comes with a built in tutorial. To access it type F1 then T. The tutorial covers many of the basic tasks such as cursor movement to more advanced skills such as searching and replacing text.

References – from basic commands to the full manual

Created by: Daniel J. Hood, August 2000