Aquamacs/Emacs Key Binding List

This is my list of common key bindings, useful as a reference, but not complete.

Movement
C-p previous line
C-n next line
C-b backward
C-f forward
Esc-b – by word
Esc-f
C-a – beginning of line
C-e – end of line
Esc-a – back sentence
Esc-b – forward sentence
Esc { – back para
Esc } – forward para
C-v scroll down
Esc-v scroll up
Esc > – end of file
Esc < – beginning of file
Esc x goto-line
Esc n do something n times, type before command
C-u similar to above but does 4, 16, 64, etc.
C-l redraw screen
C-SPC set mark
M-‘ pop buffer mark
C-x C-SPC pop global mark

Delete Text
C-d delete char
Esc-d kill word
C-k kill line
C-x u Undo
C-/ Undo
C-_ Undo
M-x flush lines RET re RET – remove lines that match regex

Format Text
Esc-q – reformat paragraph
C-t transpose chars
Esc-t transpose words
C-x C-t – transpose lines, point on second line
Esc – ; – uncomment text

Capitalization
Esc-c – Cap first letter
Esc-l – Lower case first
Esc-u – Upper case word

Spelling
M-x ispell-buffer
Esc-Tab – ispell complete word

Files
C-x C-f – Find file
C-x C-q – open read only buffer
C-x r – change to read only
C-x C-v – Find alternate file
C-x i – insert file at position
C-x C-s – Save file
C-x s – save all files
C-x C-w – write file
C-x C-c – Exit Emacs

Misc
C-g – Stop command
Esc Esc Esc get out of recursive editing
C-x z – repeat command hit z to keep repeating
C- – complete word
Esc . – find tag
C-x 4 . – find tag other window
Esc , – find next in loop
Esc-x tag-search – search by re
Esc-x tag-apropos – gives buffer with list from re

Buffers
Esc-x revert-buffer – start from scratch w/out changes
C-x b Move another buffer
C-x k Kill buffer
Esc-x kill-some-buffers
Esc-x rename-buffer

Windows
C-x 2 or C-right – divide current window horizontally
C-x o switch to other window
C-x 0 delete current window
C-x 1 delete all but this one
Esc C-v scroll other window
C-x 4 f – find file in other window
C-x 4 b – buffer in other window
C-x ^ – make window bigger
C-x } – make window larger horizontally
C-x { – make window smaller horizontally

C-x C-b – get buffer list
d or k – delete
u – undo delete
s – save
x – execute
% – toggle read / write
~ – mark as unchanged
1 – display in other window
2 – display this and next in windows
f – display in place of buffer list
m – mark for display
v – display marked buffers
o – replace other window w/ this one
q – quit buffer list

Narrowing
disabled by default
(put ‘narrow-to-defun ‘disabled nil)
(put ‘narrow-to-page ‘disabled nil)
(put ‘narrow-to-region ‘disabled nil)
C-x n n – narrow to region
C-x n d – narrow to defun
C-x n p – narrow to page
C-x n w – remove narrowing

Dired
C-x d – dired mode
c – copy file
d – flag for deletion
D – queue for immediate delete
e – find file
f – find file
g – reread directory from disk
G – change group permissions
k – remove line from display
m – mark with *
n – next line
o – find file in other window
C-o – display file in other window
P – print
q – quit dired
Q – query replace string in marked files
R – rename file
u – remove mark
v – view file
x – delete flagged with D
Z – compress or uncompress file
Esc Del – remove marks from all files
~ – flag backup files for deletion, C-u ~ deletes
* – mark executables
# – flag autosave files for deletion, C-u # deletes
. – flag numbered backups for deletion
/ – mark directories with *
= – compare files with marks
Esc = – compare with backup
! – do shell command
Esc } – mark next file
Esc { – mark prev file
%d – flag for deletion by regex
%m – mark by regex
+ – create directory
> – move to next directory
< – move to previous directory
s – toggle sort between date and filename

Slime
C-c C-l – load in slime
C-c C-k – run in slime
C-c C-e – evaluate expression in slime
M C-x – evaluate current expression
M– M-x slime – pick lisp you want

Copy & Paste
C-space – mark
M-w kill-ring-save – copy
C-y – paste
Esc-y – retrieve next item on kill ring
C-x C-x – exchange-point-and-mark
Esc h – mark paragraph
C-x h – mark whole buffer
C-x p – mark current page
Esc-w – kill ring save (for copy)

Rectangles
C-x r t – add to beginning of each line
C-x r k – kill-rectangle
Cut rectangle – block
mark block, then M-x kill-rectange
Add to end of each line
M-x query-replace-regex (qrr) RET $ RET text RET

Macros
C-x ( – start recording
C-x ) – end recording
C-x e – execute last macro
M-x apply-macro-to-region-lines

Search & Replace
C-s – search forward
C-r – search reverse
C-s C-s – repeat previous search
C-mx qrr – search & replace w/ regex
Esc-x replace-string RET old RET new RET
Esc-% – query replace, spc or y to approve, del or n to skip, ! replace all – don’t ask
C-r – recursive edit, Esc C-c to continue with replacements
Esc C-s RET – re-search-forward
Esc C-r RET – re-search-backward
Esc C-s – isearch-forward-regex
Esc C-r – isearch-backward-regex

By Directory
C-x d (dired) m to mark, u to unmark, Q to do query replace regex

Indent Text
C-option-\

Bindings
C-h b – show key bindings for mode
C-h t – tutorial
C-h k C-x i – describe-key
C-h f function-name – describe function
C-h m – show key bindings for major and minor mode
C-h – show all keys w/ that prefix
C-h C-h – list all functions
C-u M-x apropos-variable RET -mode-hook$ RET.

Bookmarks
C-x r m Set bookmark
C-x r b jump to bookmark
C-x r l bookmark list
bookmark-rename
bookmark-delete
bookmark-save
d mark for deletion
r rename
s save
f display
m mark to be displayed
v display marked
t toggle paths
w display file location
x delete flagged bookmarks
u remove mark
q exit bookmark list

Shell Mode
Esc ! run shell command
Esc | run shell command on region
C-u Esc | run shell command on region, output in current buffer
Esc-x shell
C-c C-c terminate like normal C-c
Esc p previous commands
Esc n subsequent commands
C-c C-o kill extra output
C-c C-r go to top of last command
C-c C-e go to end of last output
C-c C-p previous output group
C-c C-n next output group
Esc x rename-uniquely – rename shell so you can have another
C-u Esc-x shell – run another shell
Esc-x rename-buffer

HTML Entities
url-insert-entities-in-string

Calendar
. go to today
C-f – forward day
C-b – backward day
C-p – backward week
C-n – forward week
Esc } – forward month
Esc { – backward month
C-x ] – forward year
C-x [ – backward year
C-a – beginning of week
C-e – end of week
Esc-a – beginning of month
Esc-e – end of month
Esc < – beginning of year Esc > – end of year
g d – go to day
o – other month
C-x < – scroll forward one month C-x > – scroll backward one month
Spc – scroll other window
x – mark holidays
a – list holidays

Diary
i d – insert diary
i w – weekly
i m – monthly
i y – yearly
i c – insert cyclic
i b – insert block
i a – insert anniversary
q – quit
p d – print day of year
h – display todays holidays
d – view diary entries
s – show all diary entries
Esc = – count days in region
M – phases of moon
S – sunrise/sunset/long/lat

Python Mode
C-c C-c – Execute buffer
C-c C-d – Trace the stack of process being executed
C-C C-h – Get context based help
C-c Tab – Indent a region
C-c C-k – mark a block
C-c C-l – shift region left
C-c C-r – shift region right
C-c RET – execute buffer with output in new window
C-c C-n – next statement
C-c C-p – previous statement
C-c C-u – up one block
C-c C-s – execute python command
C-c C-t – toggle shells
C-c C-v – python version
C-c ! – python shell
C-c # – comment region
C-c :: – check indent offset
C-c | – Execute region

Org Mode
M-x org-mode
C-c C-o – open link
C-c C-l – edit link
M-RET – new entry
S-M-RET – new indented entry
C-c . – add timestamp

IRC
M-x irc

Paredit Mode
see cheat sheet documents/books/paredit.pdf
M-) – slurp
M-( – barf
M- – kill backwards
M- – kill forwards

Magit
C-c C-m – magit-status
s – stage files
i – ignore file
u – unstage
k – discard staged changes
c – to write commit message C-c C-c to commit
C-x 4 a – write changes to ChangeLog
l l – repository history
l L – more verbose log
d or D – diff
t t – lightweight tag
t T – annotated tag
z z – stashing
b c – change branch
b B – create new branch and switch to it
b V – list branches ?
m m – initiate a merge
R – rebase
P p – git push
f f – git remote update
F p – git pull
M u – update submodules
M i – initialize submodules
M b – update and initialize submodules
M s – sync remote url config settings in .gitmodules
: run git command

Weblogger Mode
M-x weblogger-setup-weblog
M-x weblogger-start-entry

C-x C-s — post-and-publish current buffer to the weblog.
Calling weblogger-publish-entry with an prefix argument
(i.e. C-u C-x C-s) will prompt for which weblog
to use.
C-c C-c — save as draft and bury the buffer.
C-c C-n — post (but not publish) the current entry and
load the next entry.
C-c C-p — post (but not publish) the current entry and
load the previous entry.
C-c C-k — delete the current entry.
M-g — synchronise weblogger.el’s idea of the entries available
with the weblog server.
C-c C-t m — edit the main template.
C-c C-t a — edit the Archive Index template
C-c C-s s — Change the server being used.
C-c C-s w — Change the weblog.
C-c C-s u — Change the user (re-login).

Textmate
⌘T – Go to File
⇧⌘T – Go to Symbol
⌘L – Go to Line
⇧⌘L – Select Line (or expand Selection to select lines)
⌘/ – Comment Line (or Selection/Region)
⌘] – Shift Right (currently indents region)
⌘[ – Shift Left (not yet implemented)
⌥⌘] – Align Assignments
⌥⌘[ – Indent Line
⌥↑ – Column Up
⌥↓ – Column Down
⌘RET – Insert Newline at Line’s End
⌥⌘T – Reset File Cache (for Go to File)

SLIME: The Superior Lisp Interaction Mode for Emacs (minor-mode).
Commands to compile the current buffer’s source file and visually
highlight any resulting compiler notes and warnings:
C-c C-k – Compile and load the current buffer’s file.
C-c M-k – Compile (but not load) the current buffer’s file.
C-c C-c – Compile the top-level form at point.

Commands for visiting compiler notes:
M-n – Goto the next form with a compiler note.
M-p – Goto the previous form with a compiler note.
C-c M-c – Remove compiler-note annotations in buffer.

Finding definitions:
M-. – Edit the definition of the function called at point.
M-, – Pop the definition stack to go back from a definition.

Programming aids:
C-c TAB – Complete the Lisp symbol at point. (Also M-TAB.)
C-c RET – Macroexpand once.
C-c M-m – Macroexpand all.

Cross-referencing (see CMUCL manual):
C-c C-w c – WHO-CALLS a function.
C-c C-w r – WHO-REFERENCES a global variable.
C-c C-w s – WHO-SETS a global variable.
C-c C-w b – WHO-BINDS a global variable.
C-c C-w m – WHO-MACROEXPANDS a macro.
C-M-. – Goto the next reference source location. (Also C-c C-SPC)

Documentation commands:
C-c C-d – Describe symbol.
C-c C-a – Apropos search.
C-c M-d – Disassemble a function.

Evaluation commands:
C-M-x – Evaluate top-level from containing point.
C-x C-e – Evaluate sexp before point.
C-c C-p – Evaluate sexp before point, pretty-print result.