Emacs Quick Reference


C followed by a “-” and a letter means hold down the <CONTROL> key while pressing the appropriate letter.
M followed by a “-” and a letter means hold down the <META> key (diamond on the Sun keyboard - not the <ALT> key); on keyboards without an <ALT> or <META> key, it means depress and release the <ESC> key followed by the appropriate letter.

Session

C-x C-c

exit emacs

C-x C-s

save a file back to disk

M-!

execute a shell command

M-|

run a shell command on region

C-u M-|

filter a region through a shell command

Search

C-s string

search forward for “string

C-s

repeat previous search forward

C-r string

search backward for “string

C-r

repeat previous search backward

C-M-s string

regular expression search for r.e. “string

M or <ESC>

escape incremental search (any command escapes)

<ENTER>

set string mark to the point where cursor had been before the search

Cut/Copy/Paste, Mark

“Marking” sets a stake in the sand. A region to be cut or copied comprises the text between the mark and the cursor (point).

C-@ or C-<SPC>

set mark here

C-x C-x

exchange point and mark

M-w

copy

C-w

cut

C-y

paste (“yank”)

Delete and Kill

“Deleting” merely removes the text, “Killing” also copies it to the paste buffer

<DEL>

delete backward one character

C-d

delete forward one character

M-<DEL>

delete backward one word

M-d

delete forward one word

M-z c  (char)

kill to next occurrence of character “c

C-k

kill to end of line

C-y

yank back last thing killed (“paste”)

Replace

M-%

interactively replace a test string

M-replace-string

replace string with string mark to end of file

Cursor Movement

C-f

forward one character

C-b

backward one character

C-n

to next line

C-p

to previous line


M-f

forward one word

M-b

backword one word


C-a

to beginning of line

C-e

to end of line


n M-r

cursor to line n of screen


M-<

to beginning of file

M->

to end of file


C-v

forward one screen

M-v

backward one screen


C-<UP-ARROW>

up one paragraph

C-<DOWN-ARROW>

down one paragraph

Numeric Arguments

Some commands have a numeric argument, typically a “repeat count”, “distance” measure or line number. These are specified with a numeric prefix, multiple digits and negative numbers permitted. Negative numbers typically denote movement in the opposite direction.

M- 0..9

numeric argument (denoted herein as n)

C-0..9

numeric argument (denoted herein as n)

Scroll Screen

n C-v

move forward n lines (scroll up)

n M-v

move backward n lines (scroll down)

C-l

scroll current line to center of screen

n C-l

scroll current line to line n of screen

Error Recovery

C-u or C-_

undo last command

C-g

abort partially typed or executing command

C-l

redraw garbled screen

M-revert-buffer

restore a buffer to its original contents

M-recover-file

recover a file lost by a system crash

Files

C-x C-f

read a file into emacs

C-x C-s

save a file back to disk

C-x i

insert contents of another file into this buffer

C-x C-v

replace this file with the contents of file you want

C-x C-w

write buffer to specified file

Getting Help

C-\ t

Tutorial recommended for new emacs users

C-x 1

get rid of help window

C-M-v

scroll help window

General

C-\ t

Tutorial suggested for new emacs users.

C-x C-c

exit emacs

C-k key

describe meaning of key “key

M-- M-u

convert previous word to Upper case

M-- M-l

convert previous word to Lower case

M-- M-c

convert previous word to initial Capital case

Multiple Windows

C-x 1

delete all other windows

C-x 0

delete this window

C-x 2

split this window in half vertically

C-x 5

split this window in half horizontally

C-M-v

scroll other window

C-x o

switch cursor to another window

Buffers

C-x b

select another buffer

C-x b bname

create a buffer named “bname

C-x C-b

list all buffers

C-x k

kill a buffer

Spelling Check

M-$

check spelling of current word

M-spell-region

check spelling of marked region

M-spell-buffer

check spelling of entire buffer


Additional help is available in man emacs.

(adapted from: http://vertigo.hsrl.rutgers.edu/ug/emacs_qref.html)