Emacs keyboard bindings

Keyboard bindings in Emacs are managed via general.el:

  • To show all of your documented bindings, press C-h B (M-x general-describe-keybindings). Thankfully this does not show every single binding, because that would be overwhelming. This only shows those bindings that are documented in your init.el via the use-package :general config. Use C-u C-h B to filter the table to the current buffer minor modes.
  • To see a complete list of bindings for the current buffer, press C-h b (M-x describe-bindings). This shows an exhaustive list, but only for the current buffer modes.

As you learn new keybindings, you should document each one in your own init.el, and then they will show up in the general-describe-keybindings list. This way you can “own” the default keybinding and it creates your own personalized cheat sheet:

  ;;; Example:
  ;;; Your custom global bindings for Emacs builtin functions::
(general-define-key
 "C-h B" 'general-describe-keybindings
 "s-b" 'quick-switch-buffer
 "s-B" 'buffer-menu-other-window
 "C-x B" 'buffer-menu-other-window
 "s-o" 'browse-url
 "C-;" 'comment-region                ; C-u C-; to uncomment
 "s-<down-mouse-1>" 'mouse-drag-region-rectangle
 )

;; The Emacs default bindings that you did not change, but you still
;; want to remember (these will show up in general-describe-keybindings):
(general-define-key
 "M-SPC" 'cycle-spacing   ; If you document it, you will use it.
 "M-h" 'mark-paragraph    ; C-h B is like your personal cheat sheet.
 "C-h b" 'describe-bindings
 "C-x 4 c" 'clone-indirect-buffer-other-window)

;; To create global keybindings for optional packages, do this inside
;; the use-package :general config:
(use-package amx
  :general
  ("M-x" 'amx
   "<menu>" 'amx))

;; You can customize the bindings of specific modes too:
(use-package paredit
  :general
  (:keymaps 'paredit-mode-map
            "C-<right>" nil
            "C-<left>" nil
            "s-<right>" 'paredit-forward-barf-sexp
            "s-<left>" 'paredit-forward-slurp-sexp))

Here we capture the general-describe-keybindings output in org-babel block:

;; Capture Emacs general keybindings in org-mode block:
(with-temp-buffer
  (let ((output-buffer (current-buffer)))
    (with-current-buffer "*General Keybindings*"
      (copy-to-buffer output-buffer (point-min) (point-max))))
  ;; prepend two spaces to every line to circumvent regular org-mode parsing:
  (replace-regexp-in-string "^" "  " (buffer-string)))
  • Local Keybindings
  • Global Keybindings
key command previous
M-SPC cycle-spacing cycle-spacing
M-h mark-paragraph mark-paragraph
C-h b describe-bindings describe-bindings
C-x 4 c clone-indirect-buffer-other-window clone-indirect-buffer-other-window
C-= default-text-scale-increase nil
C-- default-text-scale-decrease negative-argument
M-x amx execute-extended-command
<menu> amx execute-extended-command
s-<up> org-previous-visible-heading nil
s-<down> org-next-visible-heading nil
C-c o k org-babel-remove-result nil
C-c g magit-status nil
s-s avy-goto-word-1 nil
C-c s avy-goto-char nil
C-c S avy-goto-word-1 nil
s-a lsp-execute-code-action nil
C-c t my-vterm-toggle nil
M-o ace-window nil
s-SPC set-rectangular-region-anchor nil
s-n mc/mark-next-like-this nil
s-N mc/mark-all-like-this nil
<f5> whisper-run nil
M-<f5> say-buffer-from-point say-buffer-from-point
C-c C-g gptel-menu nil
M-y counsel-yank-pop yank-pop
C-h B general-describe-keybindings general-describe-keybindings
s-b quick-switch-buffer ivy-switch-buffer
s-B buffer-menu-other-window ibuffer-list-buffers
C-x B buffer-menu-other-window ibuffer-list-buffers
s-o browse-url ace-window
C-; comment-region comment-region
s-<down-mouse-1> mouse-drag-region-rectangle mouse-drag-region-rectangle
  • Paredit-Mode-Map Keybindings
key command previous
C-<right> nil paredit-forward-slurp-sexp
C-<left> nil paredit-forward-barf-sexp
s-<right> paredit-forward-barf-sexp nil
s-<left> paredit-forward-slurp-sexp nil
  • Gptel-Mode-Map Keybindings
key command previous
C-c C-c gptel-send nil
  • Dired-Mode-Map Keybindings
key command previous
C-c C-q dired-toggle-read-only nil
  • Emacs-Lisp-Mode-Map Keybindings
key command previous
s-e eval-defun nil
M-; paredit-comment-dwim nil