Supercomputing Institute Technical User Support

Basic Emacs Editing

There are two ways to start emacs to create or modify the file "my.file".

  1. If you have connected to another machine using "rlogin" or "telnet" and you haven't set the DISPLAY variable, type
    emacs my.file
    This command will start emacs in the existing window.

    otherwise,

  2. type
    emacs my.file &

    This command will pop up a new window and run emacs in this window. The '&' at the end of the line runs emacs in the background and permits you to type more commands.

In either case, you will see something similar to the following.

There are three parts to an emacs window. The top part is the work area, where you type text. The "Mode Line" would be better named "Information Bar". It contains information about the file that you are editing. In the above picture, the file is called "intro-emacs.html". The "**" indicates that the file has been modified.

The "Mini Buffer" should be called "Command Area". Commands for the emacs editor are entered in this area.

To get started, all you need to do start typing. Use the backspace key to delete charactors in front of the cursor. If you want to change something elsewhere in the document either point the mouse where you want to make a change and click the left mouse button, or use the arrow keys to move the cursor to the place where you want to make a change.

To save the file type C-x C-s, that is press the control key and the 'x' key at the same time, then press the control key and the 's' key at the same time. The file will be saved. To quit emacs type C-x C-c. That's all you need to know to use emacs. Other commands give you more power. One such command, C-k, kills part of the line that the cursor; it kills from the cursor to the end of the line.

The panic button is C-g (control and the 'g' at the same time). Hit this several times if necesary. Emacs will just beep at you if it isn't.

Summary of Basic Emacs Commands

backspace Delete the character in front of the cursor.
arrow keys Moves the cursor.
Point the mouse and click the left mouse button Moves the cursor.
C-x C-s Saves the file.
C-x C-c Quits
C-k Kill from the cursor to the end of the line
C-g Panic Button
Emacs creates a backup of the file when you start working with the file. The name of the file is the original file name followed by '~'. For my.file, the backup file is called my.file~. Emacs also periodically write a backup to disk. If the system crashes while you are editing a file using emacs, you will not loose all your changes; probably only the last 30 or so. You can recover this these changes if necessary.

This information is available in alternative formats upon request by individuals with disabilities. Please send email to alt-format@msi.umn.edu or call 612-624-0528.

HOME | QUESTIONS | FEEDBACK
Events | Links | People | Publications | Support | Welcome
 


URL: http://www.msi.umn.edu /software/emacs/tutorial/emacs-basics.html
This page last modified on Wednesday, 23-Apr-2008 11:08:46 CDT  
Please direct questions or problems to help@msi.umn.edu  
Website related questions or problems should be directed to webmaster@msi.umn.edu
The Supercomputing Institute does not collect personal information on visitors to our website. For the University of Minnesota policy, see www.privacy.umn.edu.