5/2/12

Emacs Keyboard Shortcuts

GNU Emacs v22.1.1 (mac-apple-darwin)
ctl  control key
met  escape / option / alt key  (settings -> keyboard -> use option as meta key)
cmd  command key / apple key

//FILES, BUFFERS
ctl + X, ctl + F        open file, find file
ctl + X, ctl + V        find alternate file
ctl + X, ctl + S        save
ctl + X, ctl + W        save as
met + X, revert-buffer  revert
ctl + X, K              close, kill buffer
ctl + X, ctl + Q        toggle buffer read-only
ctl + X, ctl + B        list buffers
ctl + X, B              toggle between 2 buffers
ctl + x, B, [temp]      new temp buffer
ctl + X, right          select next buffer, loop
ctl + X, left           select prev buffer, loop
ctl + G                 abort command, escape minibuffer

//NAVIGATE
met + V                 page up
ctl + V                 page down
met + <                 move cursor to start of file
met + >                 move cursor to end of file
ctl + A                 move cursor to start of line
ctl + E                 move cursor to end of line
met + B                 move cursor left 1 word
met + F                 move cursor right 1 word
ctl + L                 center current line in window
cmd + right             focus next window, loop
ctl + X, RM             set bookmark
ctl + X, RB             goto bookmark
met + X, goto-line, 42

//EDIT
ctl + J                 new line with indentation
ctl + M, ctl + K        delete sentence
met + C                 capitalize word, repeat
met + U                 uppercase word, repeat
met + L                 lowercase word, repeat
ctl + X, I              insert file
ctl + X, U              undo
met + /                 abbreviation
met + X, abbrev-mode    word abbreviation
         ctl + X, AIL   add-inverse-local
         [abb]          abbreviation, br
         [def]          definition,   <br />

;LISP, SHELL
ctl + met + X           define function, cursor outside last paren
ctl + X, ctl + E        eval expression, eval-last-sexp
ctl + G, Q              abort command, quit debugger, lisp error
met + !                 run shell command, ls -1alt ~/*.txt

//MISC
ctl + X, ctl + C        quit/exit
cmd + I                 apple terminal inspector
ctl + H                 help
ctl + H, M              describe mode
ctl + Z                 suspend
FG                      restart from suspend, fg = foreground

//SEARCH
ctl + S, [text]         search, i-search, incremental
         ctl + S        search forward, find next match
         enter          stop search
ctl + R, [text]         search reverse
         ctl + R        search reverse, find previous match
ctl + S, ctl + W        search current word at cursor, cursor first letter

//REGEX SEARCH
ctl + met + S, [regex]         regex search, eg [0-9] instead of \d
ctl + S, ctl + Q, [tab]        regex search tab characters
met + X, query-replace-regexp  regex search and replace, prompt
         Y/N                   replace/do not replace, skip
met + X, replace-regexp        regex search and replace all, no prompt


CRM  BUFFER      SIZE  MODE              FILE
.%   file1.txt   1234  Text              ~/file1.txt
  *  file2.el     500  Emacs-Lisp        ~/file2.el
  *  *scratch*    100  Lisp Interaction
  *  *Messages*   200  Fundamental
CRM
.   current
 %  read only
  * modified

MODE LINE
-uu-:---F1  file1.txt  (write)
-uu-:%%-F1  file1.txt  (read-only)
-uu-:**-F1  file1.txt  (edit)
-uu-:%*-F1  file1.txt  (read-only, edit)