Indiana University
University Information Technology Services
  
What are archived documents?

GNU Emacs Quick Reference Guide

For more information on how to type the Emacs commands listed below (not an exhaustive list), see In Emacs, how are keystrokes denoted? Also, note that "S-exp" refers to a "syntactically recognizable expression", a bit of Emacs jargon that applies mostly to editing Lisp source code.

Moving around in the buffer

  By char: By word: By line: By S-exp: By page:
Forward: C-f M-f C-n M-C-f C-v
Backward: C-b M-b C-p M-C-b M-v
Beginning:     C-a   M-<
End:     C-e   M->

Deleting/Killing (cutting text)

  By char: By word: By line: By S-exp: By region:
Forward: C-d M-d C-k M-C-k C-w
Backward: Del M-Del      

Note: Sometimes Del brings up Emacs Help. If it does, use C-h instead.

Characters that have been deleted (as opposed to killed) can only be restored by the undo command, either C-x u or C-_  (Ctrl-underscore).

In Emacs, cutting and pasting text is called killing and yanking. Killed items can be yanked back into the buffer at any point with the yank command, C-y . This is the preferred method of moving text. You can yank the text any number of times. M-y will bring back previous kills.

The region is the text between point (the cursor) and mark. You can set the mark at the point's current position by typing C-SPC or C-@ . You can then move the point, leaving a region between point and mark.

Incremental searching

Forward: C-s
Backward: C-r

A prompt will open at the bottom of the screen. Type enough of a search string until an occurrence of the desired string appears in the window.

To stop the search, press Esc. To find the next occurrence of the string, press C-s or C-r again.

Note: C-s often causes problems with flow control. If you try to use C-s on a terminal with flow control, the screen will freeze until you press C-q . If you don't have flow control in your terminal connection, and C-s does not do anything in Emacs, it may be that C-s has been disabled because of this problem. For more information, see In Emacs, how do I use commands bound to C-s and C-q (or any key) if these keys are filtered out?

String replacement

M-% executes the query-replace function. You will be prompted for two strings. Beginning at the point, Emacs will then search for and stop at every occurrence of the first string. Press the Spacebar to replace this instance of the first string with the second. Press Del to skip replacement for this occurrence. Press  !  (exclamation point) to replace all matches in the buffer. Press Enter to end the query-replace, or press  .  (period) to make a single replacement and stop.

Moving from buffer to buffer and window to window

C-x C-b Prints a list of the available buffers
C-x b Asks you which buffer to select
C-x o Moves you into the other window on the screen
C-x 1 (numeral 1) Deletes all windows except the one with the cursor

Reading/Saving files and exiting Emacs

C-x C-f Reads a file into Emacs
C-x C-s Saves the current buffer (See notes about C-s above)
C-x C-c Saves all modified buffers and exits Emacs

Accessing online help

C-h Displays help window
M-x help Displays help window (alternate method)
C-h t Shows the tutorial
C-h a Shows commands matching a string
C-h i Enters the GNU Info documentation browser

More information

For more information, see the GNU Emacs manual.

At Indiana University, to get support for personal or departmental Linux or Unix systems, see At IU, how do I get support for Linux or Unix?

Also see:

This is document abcg in domain all.
Last modified on August 22, 2008.
Please tell us, did you find the answer to your question?