-->
Emacs - How to Use

Emacs - How to Use

Emacs (derived from Editing MACroS) is a popular text editor used mainly on UNIX-based systems by programmers, engineers, students, and system administrators. It was created by Richard Stallman at MIT. It is written in LISP and provides advanced features that let you add, delete, insert, and otherwise manipulate text. Emacs is commonly used to enter the source code for programs. Emacs also offers a number of convenient capabilities such as the ability to initiate a program compiler and to handle e-mail from within the editor.

A popular version of Emacs is GNU Emacs. This is the version used by the TAMU Computer Science Department. Emacs has an X-windows version too named XEmacs.

Pre-requisite information

You should be able to access your CS Unix account by logging on to the CS unix server interactive.cs.tamu.edu. If you are unable to log in, go to the helpdesk in Room # 210.

Entering Emacs

The usual way to invoke Emacs is with the shell command emacs. Once you log in to your Unix CS account, at the prompt, type
emacs filename

Note : On a text-only terminal(putty or Tera Term), the Emacs display occupies the whole screen. On the X Window System, Emacs creates its own X windows to use.

If filename exists, Emacs clears the screen and displays the contents of the file else Emacs clears the screen and then displays an initial help message and copyright notice as shown (Fig. 1).

Fig01
Fig 1.

Note : In Emacs, usually keystrokes/key combinations start with Control or Alt, which correspond to the Ctrl or Alt keys on the keyboard. Hence, if a keystroke is Control-q, it is denoted at C-q and indicates that you need to press the “Ctrl” key and the letter “q”. Similarly, Alt-q will denoted as M-q and indicates that you need to press the “Alt” key and the letter “q”.

Emacs works on the concept of buffers. Any file that you open using Emacs is a buffer. Hence, buffer and file shall be used interchangeably in this tutorial.

Exiting Emacs

To exit emacs, press Ctrl x Ctrl c. If the file you are editing has been modified you will be prompted to save the changes. Respond with a yes(y) or no(n). You will be brought back to the command prompt.

Getting Help
Emacs has extensive online help, most of which is available via the help key, C-h. Type C-h twice to see a list of subcommands; type it three times to get a window describing all these commands

Some of the most useful help commands are:

Note: In Emacs, most editing commands(move, delete, etc) are arranged around textual objects (typically characters, words, lines and paragraphs, though this is customizable according to the mode you are working in).

Move commands

Emacs provides many motion commands, which are arranged around textual objects. All commands take numeric arguments are repetitions. Following are some motion commands that are available :

Edit commands


To Top of Page To Top Of Page Printer Friendly Version

©CSG Helpdesk

Valid CSS!