Emacs Reference

Below is an abbreviated emacs command reference. This is by no means an exhaustive list. A slightly more complete list is here. You can get better at emacs by doing the emacs tutorial, by pressing C-h t.

Buffers and Windows

C-x C-ffind file (open in current buffer)
C-x C-ssave contents of current buffer
C-x C-ckill (close) Emacs
C-x ssave all buffers
C-x C-wsave current buffer with specified name
C-x kkill (close) current buffer
C-x C-blist existing buffers
C-x bselect buffer by name
C-x 2split current window in two vertically
C-x 3split current window in two horizontally
C-x 0delete the current window
C-x 1delete all windows but the current
C-x oswitch to other window
C-M-vscroll other window down
C-fmove cursor forward
C-bmove cursor backward
C-nmove cursor to next line
C-pmove cursor to previous line
M-fmove cursor forward one token
M-bmove cursor backward one token
C-lcenter screen on cursor
C-amove cursor to beginning of line
C-emove cursor to end of line
C-vmove down one screenful
M-vmove cursor up one screenful
M-<move cursor to beginning of buffer
M->move cursor to end of buffer
M-x goto-linego to line
M-amove cursor to beginning of statement
M-emove cursor to end of statement
M C-amove cursor to beginning of function
M C-emove cursor to end of function

Editing

C-<SPC> set mark (mark is the beggining of region; cursor is end of region)
C-x C-pset region to entire uffer
C-kkill (cut) from cursor to end of line
C-wkill (cut) region
M-wsave (copy) region
C-yyank (paste) what was most recently killed
M-yyank-pop (cycle though) earlier kills, after yanking
<Backspace>delete character before cursor
C-ddelete character at cursor
M-<Backspace>delete from cursor to beginning of token
M-ddelete from cursor to end of token
M-\delete horizontal space
M-;comment/un-comment region
<TAB>indent line
C-c >indent region
C-c <exdent region
C-/undo
M-/auto complete
M-qfill paragraph (useful for wrapping lines in comments)

Searching

C-sforward incremental search
C-rreverse incremental search
<RET> (when in search mode)stop searching
C-g (when in search mode)cancel search and return to where search started
M-y (when in search mode)yank most recent kill into seach string
M-% search_string <RET> replace_string <RET>query replace occurances of search_string with replace_string
y (when in query replace mode)replace highlighted search_string
<SPACE> (when in query replace mode)do not replace highlighted search_string
q (when in query replace mode)exit query replace mode