Emacs Cheat Sheet


Starting emacs

> emacs [Enter]
to start emacs.
> emacs filename [Enter]
to start emacs and load a file
> emacs -nw filename [Enter]
to start emacs with no new window (load file)

Quitting

[Ctrl]X [Ctrl]C
quit emacs (Can be used with impunity -- the system will prompt if the workspace has not yet been saved.)
[Ctrl]G
aborts any command in progress

Help

[Ctrl]H T
to see the tutorial
[Ctrl]H A topic [Enter]
to see help about topic
[Ctrl]X U
undo the last command

Cursor Positioning

[Ctrl]F or [>-]
forward (right) one character.
[Ctrl]B or [>-]
back (left) one character
[Ctrl]P or [^]
up one character
[Ctrl]N or [v]
down one character
[Esc]B
left one word
[Esc]F
right one word
[Ctrl]A
to beginning of line
[Ctrl]E
to end of line
[Esc]<
start of document
[Esc]>
end of document
[Esc]V
page up
[Ctrl]V
page down
[Ctrl]L
cursor in middle of screen
[Ctrl]U 20 [Ctrl]N
advance 20 lines
[Ctrl]x w
display the line number where the cursor is located
[Esc]X goto-line [Enter] 999 [Enter]
go to line number 999

Search and Replace

[Ctrl]S patterntext [Enter]
search for patterntext; cursor moves as you type. Press [Enter] once at the correct location
[Ctrl]R patterntext [Enter]
search backwards for patterntext; cursor moves as you type.
[Ctrl]S [Enter] [Enter]
search for the next occurrence
[Esc]% oldstring [Enter] newstring [Enter]
Search for oldstring and replace it with newstring. The Y key confirms each replacement, N skips it, Q to exit

Regions

[Ctrl]SPC
set mark at cursor
[Ctrl]W
kill region
[Esc]W
copy region to kill ring
[Ctrl]Y
yank back last thing killed

Loading and Saving

[Ctrl]X [Ctrl]F filename
create new filename for editing (clears workspace)
[Ctrl]X [Ctrl]F filename
load in filename for editing
[Ctrl]X [Ctrl]W filename
write (save) as filename
[Ctrl]X [Ctrl]S
resave under the current filename (based on above or name given when starting emacs)

Common Lisp

[Ctrl]X L
start Common Lisp lisp image

©1997 Fernando Lopez-Lezcano. All Rights Reserved.
nando@ccrma.stanford.edu