(macros)
Getting Started

Keybindings

Every key in Macros is bound in Steel and every binding is overridable. Keymaps are named ("fundamental" is the global map; major modes add their own), and you set one with (bind-key "<map>" "<chord>" <command>).

Notation

  • C-x — hold Control, press x.
  • M-x — hold Meta (Alt/Option), press x; or press Esc then x.
  • C-x C-f — a chord: C-x followed by C-f.
  • cmd-c — the macOS Command key (system clipboard).

In a binding these are spelled ctrl-, alt-, cmd-, shift-, e.g. "ctrl-x ctrl-f".

Motion (fundamental map)

Key Command
C-f / C-b forward-char / backward-char
C-n / C-p next-line / previous-line
C-a / C-e move-beginning-of-line / move-end-of-line
M-f / M-b forward-word / backward-word
M-< / M-> beginning-of-buffer / end-of-buffer
C-v / M-v scroll-up / scroll-down
C-M-v / C-M-S-v scroll-other-window / scroll-other-window-down
C-l recenter
M-g g goto-line-cmd
C-M-f / C-M-b forward-sexp / backward-sexp
C-M-n / C-M-p forward-list / backward-list
C-M-u / C-M-d backward-up-list / down-list
C-M-a / C-M-e beginning-of-defun / end-of-defun

Sexp and defun motion works in every language, not just Lisp; see Sexps and defuns.

Editing, kill & yank

Key Command
C-d delete-char
C-k kill-line
C-S-Backspace kill-whole-line
C-M-k kill-sexp
M-d / M-Backspace kill-word / backward-kill-word
C-Space set-mark (also pushes the mark ring)
C-u C-Space pop-to-mark-command (further C-Space keeps popping)
C-x C-Space pop-global-mark
C-w / M-w kill-region / kill-ring-save
C-y / M-y yank / yank-pop
C-/ undo
C-? redo
C-t transpose-chars
C-o open-line
M-; comment-dwim
C-q quoted-insert
Insert overwrite-mode
C-x z repeat (then z to repeat again)
C-x C-+ / C-x C-- / C-x C-0 text-scale-increase / -decrease / -reset (then + / - / 0)
cmd-= / cmd-- / cmd-0 global-text-scale-increase / -decrease / -reset
C-M-t transpose-sexps
C-M-SPC / C-M-@ mark-sexp
C-M-h mark-defun
M-\ delete-horizontal-space
C-x TAB indent-rigidly (then ← / →)
M-/ dabbrev-expand (repeat to cycle)
C-x 8 RET insert-char (by name or hex code point)
M-= count-words-region
C-x = what-cursor-position
C-x n n / C-x n d narrow-to-region / narrow-to-defun
C-x n s org-narrow-to-subtree (Org)
C-x n w widen

More editing commands without a key (delete-trailing-whitespace, align-regexp, keep-lines, flush-lines, delete-duplicate-lines) are on M-x; see Editing commands.

The system clipboard always works, including inside modal states: cmd-c / cmd-x / cmd-v (clipboard-copy / -cut / -paste).

Files, buffers & windows

Key Command
C-x C-f find-file
C-x C-s save-buffer
C-x C-w write-file (save as a new file and visit it)
C-x i insert-file
C-x C-q read-only-mode (toggle)
C-x b switch-buffer
C-x C-b ibuffer (the buffer manager)
C-x k kill-buffer
C-x 2 / C-x 3 split-window-below / split-window-right
C-x o other-window
C-x 0 / C-x 1 delete-window / delete-other-windows
C-x 4 f find-file-other-window
C-x 4 b switch-to-buffer-other-window
C-x 4 0 kill-buffer-and-window
C-x 4 C-o display-buffer (show a buffer in another window, stay here)
C-x ^ / C-x } / C-x { resize windows
C-c left / C-c right winner-undo / winner-redo (window layout history; evil: C-w u / C-w U)
C-x C-c quit

M-x rename-buffer renames the current buffer, and M-x find-file-at-point (alias ffap) opens the file or URL at point — see Files and buffers.

winner-mode records every change to the window layout — splits, sizes and which buffer each window shows. C-c left goes back to the previous layout and keeps going back on repeat; C-c right goes forward again. It's on by default; (winner-mode #f) in init.scm (the same as (set-option "winner-mode" #f)) turns it off.

In a Dired listing, C-x C-q makes the file names editable (wdired); C-c C-c renames, C-c C-k aborts.

Search, command, eval

Key Command
C-s / C-r isearch-forward / isearch-backward (literal; M-r toggles regexp)
C-M-s / C-M-r isearch-forward-regexp / isearch-backward-regexp
M-s . isearch-forward-symbol-at-point
M-% / C-M-% query-replace / query-replace-regexp
C-c o occur
M-x execute-extended-command (command palette)
M-: eval-expression
M-i completion-at-point
C-g keyboard-quit
M-! shell-command (C-u: insert the output at point)
M-| shell-command-on-region (C-u: replace the region with the output)
M-& async-shell-command
M-x grep / rgrep / lgrep search a directory, then walk the matches with M-g n / M-g p

See Shell & compile for the details.

Keyboard macros

Key Command
C-x ( / C-x ) start-kbd-macro / end-kbd-macro
C-x e call-last-kbd-macro

Bookmarks

Named positions in files that survive a restart (Emacs bookmark.el):

Key Command
C-x r m bookmark-set — bookmark point here, under a name
C-x r b bookmark-jump — pick a bookmark in Helm and jump to it
C-x r l helm-bookmarks — browse all bookmarks
M-x bookmark-delete / bookmark-rename upkeep
M-x bookmark-edit-annotation annotate a bookmark (shown in the Helm picker)

Bookmarks are stored as an s-expression file at ~/.config/macros/bookmarks (see configuration), rewritten on every change. org-capture maintains an org-capture-last-stored bookmark on the headline it just inserted.

Like bookmark.el, a bookmark can carry a free-text annotation — bookmark-edit-annotation prompts for it (the current text is prefilled; empty input clears it), and annotated bookmarks show it dimmed next to their line in C-x r b / C-x r l. Programs can use bookmark-annotation / bookmark-set-annotation! directly. Hooks (add-hook): bookmark-save-hook fires after every rewrite of the file, bookmark-load-hook after the file loads at startup, and bookmark-after-jump-hook once a jump's point has landed.

Rectangles & registers

The rest of the C-x r prefix is Emacs's rectangle and register commands. Editing commands covers them in detail.

Key Command
C-x r k / C-x r M-w / C-x r d kill-rectangle / copy-rectangle-as-kill / delete-rectangle
C-x r y yank-rectangle
C-x r o / C-x r c open-rectangle / clear-rectangle
C-x r t string-rectangle
C-x r N rectangle-number-lines
C-x SPC rectangle-mark-mode. While it's on, C-w, M-w and C-t act on the rectangle
C-x r s / C-x r i copy-to-register / insert-register (also C-x r x / C-x r g)
C-x r r copy-rectangle-to-register
C-x r SPC / C-x r j point-to-register / jump-to-register
C-x r n / C-x r + number-to-register / increment-register
C-x r w window-configuration-to-register
M-x view-register / list-registers inspect registers

Feature-specific prefixes live in their own pages: C-c C-l … for LSP, C-c p … for projects, and C-h … for help. Modal editing is available too, but off by default — in either a Vim-style (evil) or selection-first (helix) flavor.

Prefix arguments

A numeric prefix repeats the next command, Emacs-style:

Key Effect
C-u N cmd run cmd N times — e.g. C-u 10 C-n moves down 10 lines
M-N cmd shorthand for the same — M-10 C-n
C-u cmd C-u alone means 4; C-u C-u means 16, and so on
C-u 5 a self-insert works too — inserts aaaaa

The argument applies to motions and simple edits (move, kill, yank, delete, newline, undo/redo). Modal or one-shot commands (M-x, save, quit, toggles) ignore it and run once. A Scheme command reads the argument with (prefix-count) (Emacs's current-prefix-arg; 0 when none was given) and decides what it means. For example, C-u M-! inserts the command's output. Negative arguments aren't supported yet.

Rebinding

Add bind-key calls to your init.scm — it's the recommended way to bind a key. The map name for the global map is "fundamental"; mode maps are named after the mode ("org-mode", "magit-status", "dired-mode", …).

;; Rebind in the global map — pass the command name as a 'name symbol
(bind-key "fundamental" "ctrl-x n" 'next-buffer)

;; Rebind only inside a mode
(bind-key "org-mode" "ctrl-c x" 'org-todo)

;; Bind a command of your own, or an inline lambda
(define (hello) (message "hi"))
(bind-key "fundamental" "ctrl-c h" 'hello)
(bind-key "fundamental" "ctrl-c !" (lambda () (insert-string "!")))

Prefer the 'name symbol form. It names the command without evaluating it, so the binding works no matter what order your config files load in. Both your own defined commands and the built-in commands (next-buffer, find-file, magit-status, …) bind this way.

bind-key also accepts the command directly as a bare identifier (next-buffer, no quote). That form evaluates the function at bind time — a typo becomes an error when your config loads, and editor tooling like go-to-definition follows the binding — but the command must already be defined at that point. A plain string name works too, handy when pasting straight from a command list:

(bind-key "fundamental" "ctrl-x ctrl-d" next-buffer)    ; bare identity (must be defined)
(bind-key "fundamental" "ctrl-x ctrl-f" "find-file")    ; string name

define-key (the primitive)

bind-key is a thin wrapper over define-key, the lower-level primitive the keymap is built on. define-key takes a command name — a 'symbol (preferred) or a string. It resolves the name at keypress time, so it can't take a function or a lambda (use bind-key for those):

(define-key "fundamental" "ctrl-c d" 'lsp-find-definition)  ; 'symbol (preferred)
(define-key "fundamental" "ctrl-c d" "lsp-find-definition")  ; string still works

You'll see define-key throughout the bundled config and it's fully supported — reach for it when you specifically want the primitive or the exact Emacs spelling. For everyday rebinding, bind-key does everything it does and takes functions too.

To see what a key currently does, press C-h k (describe-key) and then the key. To list everything active, C-h b (describe-bindings). See Getting help.