Return to the Boston College Home Page
 
BCInfo<    A to Z    SEARCH    DIRECTORIES    CONTACT BC
 
 
 

Unix editors: emacs

The emacs editor is always in the edit mode, in a similar manner to the normal PC word processors like Word Perfect, Ami Pro, and Microsoft Word. Control of other functions is always accomplished by pressing either the control key along with another key, or by preceding another keystroke with the escape key (symbolized in this handout by <M>). Emacs has an on-line tutorial, which can be accessed by pressing ^H^H^Ht (control H, 3 times, followed by a lower case t). Note that each time one presses ^H, there is help information appearing on the bottom line of the screen, and that reminder may be sufficient for the current situation.

Note that some of the Vi commands do not exist in emacs. These commands have no command keystrokes preceding the command description. For example, there is no command to move the cursor to the end of the current word.

Emacs Commands

Cursor Movement:

^b    

Cursor left (Backward)

^n    

Cursor down (Next line)

^p    

Cursor up (Previous line)

^f    

Cursor right (Forward)

^a    

Cursor to beginning of line

^e    

Cursor to end of line (End of line)

 <M>f

Cursor forward to next word

<M>b

Cursor to beginning of current word

There is no emacs command equivlaent to these next 3 commands, but the same effect can be had using a numeric prefix for the number of lines up or down you which to move the cursor.  See the Extra Commands section for a more complete explanation.

Cursor to top of screen

Cursor to middle of screen

Cursor to last line on screen

^v          

Scroll forward 1 screen
Scroll down 1/2 screen (Control-D in vi - no emacs equivalent)
Scroll up 1/2 screen (Control-U in vi - no emacs equivalent)

<M>v

Scroll back 1 screen

^l

Repaints the screen and centers it around the line containing the cursor.

<M><

Move cursor to top line of file

<M>>    

Move cursor to last line of file


Deletion Commands

^d

Delete character under cursor

<M>d

Delete word under cursor

^k

Delete from cursor position to end of line

^k^k

Delete current line of characters and the remaining blank line

Editing Commands

Note that the next group of commands is not needed in emacs, since one is always in the edit mode.
Append text after cursor
Append at end of line
Insert text at current cursor position
Insert at beginning of line
Replace character under cursor

^o

Open a new line above current line.

Exiting from Emacs

^x^s    

Save the current buffer

<M>x save-buffer

Alternative method if the ^S key is blocked by your terminal emulator.

^x^c   

Exit from emacs. If you have changed the buffer, you will be asked if you want to save the changes. If you do not want to save the changes, you will also need to type yes in response to the are-you-sure prompt.

Saving Files

^x^s

Save the current buffer

<M>x save-buffer

Alternative method if the ^s key is blocked by your terminal emulator

Getting a new file

^x^f

Read a file. You will be prompted for the filename.


Extra Commands

<M>nn

Where nn stands for some number, <M>nn causes the next command or keystroke to be repeated nn times. Thus, <M>9 ^p causes the cursor to go up 9 lines, and <M>9 a causes 9 'a's to be put into the text.

<M>x

This causes emacs to provide you with a command line from which other commands can be entered as words. Thus <M>x save-buffer causes the current buffer to be saved. This is the same as ^x^s, but is useful when connected through a modem or through a program such as CrossTalk (Synapse) which does not allow a ^s to be transmitted to the computer at the other end of the connection.

<M>x

apropos provides help on any topic in the help index. It will prompt you for a single word topic, and attempt to find anything relevant to that topic. It may present you with a list of multiple topics from which you will have to decide which one is what you are looking for.

<space>

On the <M>x command line, if you have typed the beginning of a command, and press the space bar, emacs will attempt to figure out the command you were trying to enter, and will fill in the appropriate text until it finds an ambiguity, at which point it will show you a list of possibilities.

 

 
 

Updated: April 30, 2002
Maintained: Academic Technology Services
URL:
© 2002 The Trustees of Boston College. Legal