ARCHIVED: GNU Emacs Quick Reference Guide

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.

For more on how to type the Emacs commands listed below (not an exhaustive list), see How keystrokes are denoted in Emacs 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      
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.

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, see ARCHIVED: 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, see the GNU Emacs manual.

At Indiana University, for personal or departmental Linux or Unix systems support, see Get help for Linux or Unix at IU.

This is document abcg in the Knowledge Base.
Last modified on 2018-01-18 08:52:41.

Contact us

For help or to comment, email the UITS Support Center.