Appendix C: The Emacs Command Set

First, there is no such thing as an "official" Emacs command set. One of the main reasons why Emacs-type text editors exist is that each user is free to change the commands to suit his or her own tastes. Another reason is that there are many different implementations of Emacs editors and each will have a slightly different command set. You should consult the documentation that comes with your implementation (or the documentation that you write for your own implementation) for specifics.

That said, this appendix will list most of the default command set that comes with GNU-Emacs. It will also list my own alterations to these defaults.

Emacs-type text editors implement the "one-dimensional array of bytes" editing model. Line breaks are represented as single Newline characters, regardless of the representation used by the operating system.

Notation

The first Emacs took advantage of a particular keyboard's features. This keyboard allowed you to type all of the normal characters. In addition, both Control and Meta keys were available. These keys acted as full Shift keys, allowing the user to specify Control- and/or Meta-shifts to any key. For example, one could type:

notation
key combinations


5
5
%
Shift-5
C-5
Control-5
C-%
Control-Shift-5
M-5
Meta-5
M-%
Meta-Shift-5
M-C-5
Meta-Control-5
M-C-%
Meta-Control-Shift-5

The last two could also be written C-M-5 and C-M-%. Most current keyboards can only send the usual ASCII characters. That limitation removes the possibility of typing the multiply shifted characters and hence the need for the unusual notation. The command sets presented here will thus use the familiar caret notation, a copy of which is listed in Appendix E. There are still some systems that use extended keyboards like these. The documentation for those systems will use the original notation.

The Escape key (usually labelled "Esc") which sends the escape character is used as a prefix to make up for the missing Meta shift key. By convention, those keyboards that have an extra shift key (perhaps labelled Meta or Alt) can specify meta commands by setting bit 2^7 in characters sent from the keyboard.

Emacs commands are, by convention, always upper/lower case-independent. Thus, ^X B and ^X b both refer to the same command. The only exception is the "self-insert" command, where B inserts a "B" and b inserts a "b". Only the uppercase versions will be listed.

The terms "S-exp" and "defun," while familiar to Lisp programmers, are probably not familiar to others. "S-exp" refers to a parenthesized list and "defun" refers to a function definition. Most Emacs language modes remap these Lisp-specific commands to comparable commands for other programming languages.

Default GNU-Emacs Command List

^@
Place the mark at the point.
^A
Move to the beginning of the current line.
^B
Move backward one character.
^C
Prefix for mode-specific commands.
^D
Delete the following character.
^E
Move to the end of the current line.
^F
Move forward one character.
^G
Abort execution and return to the edit loop.
^H
Help
^I
Tab to indentation in a language-specific manner.
^J
Insert a line break and indent in a language-specific manner.
^K
Delete the text to the end of the current line; if at the end of the line, delete the line break. With an argument, delete that many complete lines.
^L
Rebuild the display from scratch, centering the point.
^M
Insert a line break, leaving the point after the break.
^N
Move down one line, staying in as nearly the same column as possible. If at the end of the buffer, grow the buffer.
^O
Insert a line break, leaving the point before the break.
^P
Move up one line, staying in as nearly the same column as possible.
^Q
Quote: Insert the following character as typed.
^R
Reverse search (see ^S).
^S
Search incrementally for a string after the point:
^R
Search for the previous occurrence.
^S
Search for the next (2nd, 3rd...) occurrence.
^?
"Untypes" the last character (including ^R, ^S, etc.)
^G
Abort search: return to starting place.
^[
Complete the search.
^Q
Quote a search command.
ctrl-XX
Complete the search and execute the XX command.
other
Add the character to the search string.
^T
Interchange the characters on each side of the point, leaving the point after the second one.
^U
Universal argument. There are two forms:
^U ^U .... <cmd>
does <cmd> 4, 16, 64, 256, ... times depending upon the number of ^Us (each ^U is a multiplier by 4).
^U <integer> <cmd>
does <cmd> <integer> times. (e.g., ^U 3 5 ^F means to ^F 35 times).
^V
Move the bottom of the current screen to the top of the screen: i.e., move down one screen.
^W
Delete the text between the point and the mark ("cut").
^X
Prefix for the ^X commands listed below.
^Y
Copy the top item from the kill ring to the point; place the mark at the beginning of the block and the point at the end ("paste").
^Z
Suspend the program's execution and return to whatever invoked the editor.
^[
Prefix for the Meta commands listed below.
^\
Undefined.
^]
Aborts a recursive edit.
^^
Undefined.
^_
Undo.


SP ... ~
Insert themselves.


^?
Delete the preceding character.


BS
Same as ^H, also BACK SPACE.
TAB
Same as ^I.
LF
Same as ^J, also LINE FEED.
CR
Same as ^M, also CARRIAGE RETURN or RETURN.
ESC
Same as ^[, also ESCAPE.
DEL
Same as ^?, also DELETE or RUBOUT (obsolete).
Help Commands:

^H ^C
Describe the copying policy.
^H ^D
Describe the distribution policy.
^H ^H
Help on help.
^H ^N
View Emacs news.
^H ^W
Describe the (lack of) warranty.
^H ?
Help on help.
^H A
Apropos (which commands deal with ...?).
^H B
Describe the current key bindings.
^H C
Briefly describe a key.
^H D
Describe a function.
^H F
Describe a function.
^H I
Invoke the "info" subsystem.
^H K
Describe a key.
^H L
Describe problems with the (current) version ("lossage").
^H M
Describe a mode.
^H N
View Emacs news.
^H S
Describe syntax.
^H T
Tutorial.
^H V
Describe a variable.
^H W
Where is ...?

Control-X (^X) Commands:

^X ^@
Flush mouse queue.
^X ^A
Add mode abbreviation.
^X ^B
Display a list of all buffers and associated information.
^X ^C
Exit editor.
^X ^D
Display the current directory.
^X ^E
Evaluate the last S-exp.
^X ^F
Ask for the name of a file and read it into a new buffer whose name is derived from the file name.
^X ^G
Cancel ^X prefix.
^X ^H
Remove mode abbreviation.
^X ^I
Indent rigidly
^X ^L
Convert the region to lower case.
^X ^N
Set the goal column.
^X ^O
Delete the blank lines around the point.
^X ^P
Place the point and the mark around the current page.
^X ^Q
Toggle the "read only" marker.
^X ^R
As ^X ^F, but mark the file "read only."
^X ^S
Save the current buffer if it has been modified.
^X ^T
Transpose lines.
^X ^U
Convert the region to upper case.
^X ^V
Find alternate file.
^X ^W
Ask for the name of a file and write the buffer to that file.
^X ^X
Exchange the point and mark.
^X ^[
Repeat a complex command.
^X $
Set selective display.
^X '
Expand an abbreviation.
^X (
Start collecting a keyboard macro.
^X )
End collecting a keyboard macro.
^X +
Add global abbreviation.
^X -
Remove global abbreviation.
^X .
Set the fill prefix.
^X /
Point to register.
^X 0
Delete window.
^X 1
Delete other windows.
^X 2
Split window vertically (one above the other).
^X 3
Split window vertically (one above the other), but stay in the first.
^X 4
Prefix for the Control-X 4 commands listed below.
^X 5
Split window horizontally (one beside the other).
^X ;
Set the comment column.
^X <
Scroll the window left.
^X =
Display the current cursor position.
^X >
Scroll the window right.
^X A
Append the region to a buffer.
^X B
Switch to a buffer.
^X D
Edit directory ("DIRED").
^X E
Invoke the last keyboard macro.
^X F
Set the fill column to the horizontal position.
^X G
Insert a register.
^X H
Place the point and the mark around the entire buffer.
^X I
Insert a file.
^X J
Register to point.
^X K
Kill a buffer.
^X L
Count the number of lines in the page.
^X M
Send electronic mail.
^X N
Narrow the editing bounds to the region.
^X O
Switch to the other window.
^X P
Narrow the editing bounds to the page.
^X Q
Keyboard macro query.
^X R
Copy a rectangle to a register.
^X S
Save some buffers.
^X U
Advertised undo.
^X W
Widen the editing bounds.
^X X
Copy to a register.
^X [
Move backward one page.
^X ]
Move forward one page.
^X ^
Grow the current window.
^X `
Move to the location implied by the next error message.
^X {
Shrink a window horizontally.
^X }
Grow a window horizontally.
^X ^?
Delete to the beginning of the current sentence.

Control-X 4 Commands:

^X 4 ^F
Find file other window.
^X 4 .
Find tag other window.
^X 4 A
Add change log entry other window.
^X 4 B
Switch buffer other window.
^X 4 D
DIRED other window.
^X 4 F
Find file other window.
^X 4 M
Mail other window.

Meta (^[) Commands:

^[ ^@
Place the point and the mark around the S-exp.
^[ ^A
Move to the beginning of the current defun.
^[ ^B
Move backward one S-exp.
^[ ^C
Exit recursive edit.
^[ ^D
Move down one level of list structure.
^[ ^E
Move to the end of the current defun.
^[ ^F
Move forward one S-exp.
^[ ^G
Format ("grind") the current S-exp.
^[ ^H
Place the point and the mark around the S-exp.
^[ ^I
Complete a Lisp symbol.
^[ ^J
Indent a new comment line.
^[ ^K
Delete the following S-exp.
^[ ^N
Move forward one list.
^[ ^O
Split line: move the rest of this line vertically down.
^[ ^P
Move backward one list.
^[ ^Q
Indent an S-exp.
^[ ^S
Incremental search forward using regular expressions.
^[ ^T
Transpose the adjoining S-exp.
^[ ^V
Scroll the other window.
^[ ^W
Append the next delete to the top item on the kill ring.
^[ ^X
Evaluate a defun.
^[ ^[
Evaluate an expression.
^[ ^\
Indent the region.
^[ SP
Insert exactly one space.
^[ !
Ask for and execute a shell command.
^[ $
Invoke the spelling checker on a word.
^[ %
Query replace: ask for an old string and a new string. At each occurrence of the old string, display it and ask for a command:
^L
Redisplay the screen.
^R
Invoke the editor recursively.
^W
Delete the old string and invoke the editor recursively.
^[
Exit.
SP
Replace the old with the new and continue.
,
Replace and wait for confirmation.
.
Replace and exit.
!
Replace the rest without asking.
^
Return to previous old string (jump to mark).
^?
Don't replace but continue.
^[ '
Set abbreviation prefix mark.
^[ (
Insert paired parentheses.
^[ )
Move past the closing parenthesis.
^[ ,
Tags loop continue.
^[ -
Make the argument negative.
^[ .
Find a tag.
^[ /
Abbreviation expand.
^[ 0 .. 9
Use digits as argument (similar to ^U).
^[ ;
Indent for comment.
^[ <
Move to the beginning of the current buffer.
^[ =
Count the lines within the region.
^[ >
Move to the end of the current buffer.
^[ @
Place the point and mark around the current word.
^[ A
Move to the beginning of the current sentence.
^[ B
Move backward one word.
^[ C
Capitalize the following word.
^[ D
Delete the following word.
^[ E
Move to the end of the current sentence.
^[ F
Move forward one word.
^[ G
Fill text in the region.
^[ H
Place the point and the mark around the current paragraph.
^[ I
Tab to tab stop.
^[ J
Indent new comment line.
^[ K
Delete the remainder of the current sentence.
^[ L
Convert the following word to lower case.
^[ M
Move back to indentation.
^[ Q
Fill the current paragraph. ^U ^[ Q means to justify the paragraph.
^[ R
Move to window line.
^[ T
Transpose the adjoining words.
^[ U
Convert the following word to upper case.
^[ V
Move the top of the current screen to the bottom of the screen: i.e., move up one screen.
^[ W
Copy the region to the kill buffer.
^[ X
Execute extended command.
^[ Y
After ^Y: Delete the just-yanked text and yank the previously killed text.
^[ Z
Zap to character.
^[ [
Move to the beginning of the current paragraph.
^[ \
Delete the spaces and tabs around the point.
^[ ]
Move to the end of the current paragraph.
^[ ^
Delete the indentation on the current line.
^[ |
Execute a shell command on the region ("pipe the region through a shell command").
^[ ~
Clear the buffer modified flag.
^[ ^?
Delete the previous word.

The Author's Command Set

This section lists the changes the author makes to the just-presented default command set.

^C
Rotate case of word: foo -> Foo -> FOO -> foo ...
^H
Delete the previous character.
^I
Just insert a TAB: no special indentation.
^J
Insert a line break and indent the new line the same as the current one.
^K
Delete lines as usual, but don't treat an argument specially.
^M
Just insert a line break: no special actions.
^N
Move to the next line: don't extend the buffer.
^T
Always transpose the two preceding characters.
^V
A slightly different move down screen.
^Z
Move up screen.
^\
Delete all white space (indentation) on the current line.
^]
Invoke keyboard macro.
^_
Suspend the program's execution and return to whatever invoked the editor.
^?
Delete the previous character with no special actions.


^X ^E
Execute one shell command.
^X ^I
Insert a file.
^X ^M
Invoke a subshell.
^X ^N
Null (to prevent typing by accident).
^X ^P
Null (to prevent typing by accident).
^X ^R
Re-read file.
^X ^T
Return to top-level editing (exit all recursive editors).
^X \
Get rid of all "^H_" strings in the buffer (used to make UNIX man pages more readable after doing "^X ^E man title").
^X C
Invoke compiler.
^X ^H
Help.
^X N
Null (to prevent typing by accident).
^X P
Null (to prevent typing by accident).
^X R
Read electronic mail.


^[ ^H
Delete previous word.
^[ ^R
Query replace.
^[ ^[
Null (to prevent typing by accident).
^[ SP
Set the mark.
^[ <
Move to the beginning of the buffer. With an argument, move to the specified line number.
^[ =
Display the number of lines in the buffer and the number of the line that the point is on.
^[ >
Move to the end of the buffer. With an argument, move to the specified line number.
^[ G
Ask for a line number and go to the specified line.
^[ I
Null (to prevent typing by accident).
^[ J
Null (to prevent typing by accident).
^[ M
Null (to prevent typing by accident).
^[ N
Null (to prevent typing by accident).
^[ O
Null (to prevent typing by accident).
^[ P
Null (to prevent typing by accident).
^[ R
Replace string (as ^[ ^R, but don't ask).
^[ S
Center the current line.
^[ Z
Null (to prevent typing by accident).
^[ \
Delete all surrounding spaces, tabs, and line breaks and re-insert one space.



Copyright 1999 by Craig A. Finseth.

Back to Top.

Back to Contents.

Back to Home.