1. Display
  2. Search and RegExp
  3. Various
    1. Speedbar
    2. Navigation
      1. Ido & flex matching for fast file/buffer location
      2. File searching
  4. Libs
  5. Links
  6. Emacs usability
    1. The Problem
    2. The Solution
      1. Ideal solution
      2. Actual solution

My personal Emacs/Aquamacs mini-reference. (Without the very elementary stuff that I still happen to remember.)


  • Windows

    • Resize split window: Mouse-1 click on the bar between them and drag it.

Search and RegExp


  • C-S forward (see isearch-forward[-regexp])

  • C-R backward

  • M-x query-replace[-regexp] - (use isearch-forward-regexp to build the regexp as it interactively displays the matches)

  • Repeat: To repeat or find the next regexp or normal match just press C-r or C-s (w.r.t. desired direction) again (once or twice)

RegExps in Emacs.

  • Key differences: Escape ()| to make them special (group/alternative). Use etc. instead of \d. [a-z] is case insensitive. Non-greedy: .+?.

  • Build an RE interactively (shows matches): M-x re-builder

    • ! You have to switch into the string syntax either interactively (C-c TAB string RET or C-c C-i in the builder) or by default (in the config: (require ’re-builder) (setq reb-re-syntax ’string)); (default is read for Lisp source code, other are functio-like rx, sregex, lisp-re)

    • Match TAB: C-q TAB, newline: C-q C-j

    • C-c C-i: toggle case-sensitivity; move between matches: C-c C-s, C-c C-r

    • (Note: You can simple copy the RE and paste it e.g. into C-M % (query replace regexp))

    • C-c C-q quit the re-build

    • See RE syntax (\s- whitespaces, \w word constituent)

    • re-builder+ allows interactive building of RE for search and [query-]replace-regexp


  • M-z zap-to-char - delete all to the given char, inclusive (", ), etc.); (I’ve rebound it to zap-up-to-char)

  • C-RET (via Cua mode) - select a rectangular area ⇒ cut, yank, etc.


  • b to buffer list mode, f to file list mode, r to “previous mode”

  • t stop updating w.r.t. current buffer/frame (slowbar mode)


Ido & flex matching for fast file/buffer location

The general InteractivelyDoThings mode has the great ido-enable-flex-matching option that will automatically show matching completions for commands working on files, buffers etc in the minibufer, e.g. C-x b and copy to switch to the buffer comoyo-puppet. It’s genial!

Tip for ido-open-file (C-x C-f) with ido:

  • // starts search for files under /

  • ~/ under the home dir

  • C-d open dired in the current dir

General C-s/-r: to next/prev match. To fall back to the origina open file: C-f, buffer: C-b.

File searching

  • If using IDO: C-x C-f for ifo-find-file then M-f (ido-wide-find-file-or-pop-dir) to search for a file in the current dir and subdirs

  • IDO tip to: typing ‘**/xyz’ seems to find (after a short while) all files containing xyz in the name anywhere on the disk?? (works also without IDO, for dir/subdirs)

  • M-x find-name-dired - prompts for a dir, uses find <dir> -iname <your input> to find files by name

  • M-x locate - on Mac you might need to set it to use Spotlight


  • Sexp fold/expand is very useful for exploring source code (hide all but the first lines of all top-level forms with hs-hide-all) - the built-in hs-minor-mode can hide/show all, or hide/show/toggle one but the keys for it are cumbersome; hideshow-org makes it possible to toggle hide/show with TAB, while preserving the original TAB behavior (it does the normal TAB first only only if nothing changes does it expand/fold)

  • Using [wdired to rename files] etc.

  • ParEdit Guide (from Clojure Made Simple) - wrap with M - <delimiter>, extend it with M-); extend to a whole sexp: C-), to throw out a sexp: C-}; for backwards: (, \{

Emacs usability

The Problem

  1. It is hard to learn and remember 10s of commands and their key combinations

  2. It is hard to type finger-breaking combinations such as C-c @ C-h - see Xah Lee’s Banish Key Chords

See Xeh’s Emacs Modernization posts.

The Solution

Ideal solution

Ideally, Emacs would be more discoverable and provide context-sensitive help and offer commands based on the current context and their frequency of use.

  1. Context-sensitive action list similar to IntelliJ’s Alt-Enter, Eclipse’s Command-1: show the most used actions relevant to the current cursor point; f.ex. at “\{” show Go to matching bracket, Select block, Collapse block

  2. Inline help with the most used commands when switching to a new major/minor mode - either embedded in the buffer or a non-intrusive (and fading away?) pop-up; f.ex. for a Dired and Magit buffer

  3. Menus for less frequently used commands (remember, menus can be accessed from the keyboard)

  4. Use key sequences à la Vim instead of key chords with Ctrl-, Alt-

Actual solution

\{work in progress}

  1. ErgoEmacs-mode - more sensible key combinations, <menu> key + sequence of letters similar to Vim’s command mode

  2. OneKey? -– customizable in-buffer menus for different types of items (major-mode commands, standard keybindings, yasnippets, etc). Useful for learning keybindings, or quickly finding relevant commands.

  3. discover.el?

Copyright © 2024 Jakub Holý
Powered by Cryogen
Theme by KingMob