Emacs command bindings (an alphabetical list)
Global Command Bindings
- These should work everywhere
Specials
SPC .. ~ self-insert-command
RET newline
Commands using the Control Key
- Commands of the form control-letter
C-a beginning-of-line
C-b backward-char
C-c mode-specific-command-prefix
- e.g., specific to C-mode or text-mode or whatever
- command will typically be in the form C-c C-char
C-d delete-char
- delete current character (backspace deletes previous character)
C-e end-of-line
C-f forward-char
C-g keyboard-quit
- the general 'abandon command' command
- won't work inside a 'recursive edit' where C-] works
C-h help-command
- keep typing C-h to get more info --- seehelp commands below
C-k kill-line
- kills contents and carriage returns separately (except inside C-u)
C-l recenter
- redisplays the screen with cursor at center
- often useful just for “refresh screen”
C-n next-line
C-o open-line
- add a new line in the middle of text
C-p previous-line
C-q quoted-insert
- treat the next character (usually a control or escape character) literally
C-r isearch-backward
C-s isearch-forward
C-t transpose-chars
- one of the truly useful and unique features of EMACS
C-u universal-argument
- another --- a little like Windows “repeat”
C-v scroll-up
C-w kill-region
- more-or-less 'cut'
- however, the entire “kill ring” --- or at least a number of previous kills --- remains available
C-x Control-X-prefix
C-y yank
C-z suspend-emacs
- Commands of the form Control-symbol
C-@ set-mark-command
- mark the beginning of a region (the cursor will mark the end)
C-] abort-recursive-edit
- like C-g inside a recursive edit (don’t worry too much about it, but be prepared to use it when C-g
fails).
C-_ undo
Commands inside Help
[Click here to goback on the local link.]
- Commands of the form C-h letter --- the help-menu options
C-h a command-apropos
- like UNIX 'apropos'
- Example: C-h a file gives the commands and functions affecting files
C-h b describe-bindings
- gets you this list (in somewhat different order), without comments
C-h c describe-key-briefly
- Example: C-h c C-g gives the name of the C-g command
C-h d describe-function
C-h f describe-function
- Example: C-h d M-x undo describes the undo function
C-h k describe-key
- like C-h c, but a description rather than a name
C-h i info
C-h l view-lossage
- the last several characters typed
C-h m describe-mode
- for example, Text mode, or LISP mode
C-h n view-emacs-news
C-h C-n view-emacs-news
C-h s describe-syntax
C-h t help-with-tutorial
C-h v describe-variable
- Example: C-h v fill-prefix describes the meaning and use of “fill prefix”
C-h w where-is
C-h C-c describe-copying
C-h C-d describe-distribution
C-h C-w describe-no-warranty
C-h ? help-for-help
C-h C-h help-for-help
Commands of the form C-x something
C-x C-a add-mode-abbrev
C-x C-e eval-last-sexp
C-x C-h inverse-add-mode-abbrev
C-x TAB indent-rigidly
C-x C-l downcase-region
C-x C-n set-goal-column
C-x C-o delete-blank-lines
C-x C-p mark-page
C-x C-q toggle-read-only
C-x C-t transpose-lines
C-x C-u upcase-region
C-x C-x exchange-point-and-mark
C-x ESC repeat-complex-command
- repeat the last complex command executed
C-x $ set-selective-display
C-x ' expand-abbrev
C-x + add-global-abbrev
C-x - inverse-add-global-abbrev
C-x . set-fill-prefix
- on line wrap, use whatever is before the point on this line as a prefix
C-x / point-to-register
C-x ; set-comment-column
C-x < scroll-left
C-x = what-cursor-position
C-x > scroll-right
C-x [ backward-page
C-x ] forward-page
C-x ` next-error
- useful for interpreters/compilers which interact with EMACS
C-x f set-fill-column
- set to get line wrap, usually at values between 70 and 80
- invoke either by moving the point to the appropriate column
- or by using C-u 75 C-x f (or whatever number in place of 75)
C-x g insert-register
C-x h mark-whole-buffer
C-x j register-to-point
C-x l count-lines-page
C-x m mail
- only works with a mail system which interacts with EMACS
C-x n narrow-to-region
C-x p narrow-to-page
C-x r copy-rectangle-to-register
C-x u advertised-undo
C-x w widen
C-x x copy-to-register
C-x { shrink-window-horizontally
C-x } enlarge-window-horizontally
C-x DEL backward-kill-sentence
Window commands
[Click here to go back on the local link]
- The next bunch of commands manipulate windows inside EMACS (and are almost all useful)
C-x 0 delete-window
C-x 1 delete-other-windows
C-x 2 split-window-vertically
C-x 4 ctl-x-4-prefix
C-x 5 split-window-horizontally
C-x o move-to-next-window
C-x ^ enlarge-window
C-x 4 Commands
C-x 4 C-f find-file-other-window
C-x 4 . find-tag-other-window
C-x 4 a add-change-log-entry-other-window
C-x 4 b switch-to-buffer-other-window
C-x 4 d dired-other-window
C-x 4 f find-file-other-window
C-x 4 m mail-other-window
Keyboard Macros
[Click here to goback on the local link]
C-x ( start-kbd-macro
C-x ) end-kbd-macro
- keyboard macros are defined with C-x ( key-sequence C-x )
- “key sequence” will be interpreted as if it were a sequence of commands
C-x e execute kbd-macro
- there can be at most one keyboard macro
- it can be re-executed without a name
- other macros can be named and reused
C-x q kbd-macro-query
- what is the current keyboard macro
File/Buffer Management
[Click here to go back on the local link]
C-x C-b buffer-menu
- display the set of buffers --- allowing some to be closed
C-x C-c save-buffers-kill-emacs
C-x C-d list-directory
C-x C-f find-file
- create a new buffer for the given file
C-x C-r find-file-read-only
C-x C-s save-buffer
- save the file in the current buffer
C-x s save-some-buffers
- asks whether to save each buffer
C-x C-v find-alternate-file
- bring a different file into this buffer (usually use C-x C-f instead)
C-x C-w write-file
C-x C-z suspend-emacs
- get out of EMACS temporarily, without losing state
C-x a append-to-buffer
C-x b switch-to-buffer
- switch to the named buffer
C-x d dired
C-x i insert-file
C-x k kill-buffer
Commands using Escape (M-)
- Commands using M-C-char
- Few of these will be useful for even an experienced casual user; as usual, these few have been moved
to the front, and are commented. The rest of these commands are used mostly in recursive editing of
commands, menus, and macros.
ESC C-c exit-recursive-edit
- Unlike C-], causes the edit contents to take effect
- (although most recursive edits are ended with ENTER, or close-parens, etc.)
ESC C-s isearch-forward-regexp
- This can be useful if we are searching for something more general than a single word.
ESC C-v scroll-other-window
- This is useful for comparing two versions of a text, or doing selective copying.
ESC C-\ indent-region
ESC C-@ mark-sexp
ESC C-a beginning-of-defun
ESC C-b backward-sexp
ESC C-d down-list
ESC C-e end-of-defun
ESC C-f forward-sexp
ESC C-h mark-defun
ESC TAB lisp-complete-symbol
ESC LFD indent-new-comment-line
ESC C-k kill-sexp
ESC C-n forward-list
ESC C-o split-line
ESC C-p backward-list
ESC C-t transpose-sexps
ESC C-u backward-up-list
ESC C-w append-next-kill
- Commands using M-symbol (ESC or META key). Again, the useful ones (in my opinion) are listed
first.
M-SPC just-one-space
- Hard space --- don’t expand
M-! shell-command
- Execute a UNIX command without interrupting EMACS
M-$ spell-word
- Obvious --- can also be invoked by M-x spell-word
M-% query-replace
- Do a replace, asking each time --- can also be invoked by M-x query replace
M-( insert-parentheses
- From the mark to the point
M-< beginning-of-buffer
M-> end-of-buffer
M-[ backward-paragraph
M-] forward-paragraph
M-ESC eval-expression
M-' abbrev-prefix-mark
M-) move-past-close-and-reindent
M-, tags-loop-continue
M-- negative-argument
M-. find-tag
M-/ dabbrev-expand
ESC 0 ... ESC 9 digit-argument
M-; indent-for-comment
M-= count-lines-region
M-@ mark-word
ESC O Prefix Command
- Allowing use of C-whatever commands when the control key can’t be used.
M-\ delete-horizontal-space
M-^ delete-indentation
M-| shell-command-on-region
M-~ not-modified
Meta-commands (M-)
- Most of these are useful; M- is ESCAPE, except on machines which actually have a META key
M-a backward-sentence
M-b backward-word
M-c capitalize-word
M-d kill-word
M-e forward-sentence
M-f forward-word
M-g fill-region
M-h mark-paragraph
....M-i tab-to-tab-stop
M-j indent-new-comment-line
M-k kill-sentence
M-l downcase-word
M-m back-to-indentation
M-q fill-paragraph
M-r move-to-window-line
M-t transpose-words
M-u upcase-word
M-v scroll-down
M-w copy-region-as-kill
M-x execute-extended-command
M-y yank-pop
M-z zap-to-char
M-DEL backward-kill-word
ESC 0 commands (mostly alternatives to control commands)
ESC O A previous-line
ESC O B next-line
ESC O C forward-char
ESC O D backward-char
ESC O M open-line
ESC O P beginning-of-line
ESC O Q end-of-line
ESC O R isearch-forward
ESC O S kill-line
ESC O n delete-char
ESC O p yank
ESC O q backward-word
ESC O r next-line
ESC O s forward-word
ESC O t backward-char
ESC O u universal-argument
ESC O v forward-char
ESC O w scroll-down
ESC O x previous-line
ESC O y scroll-up
