Emacs

Table of Contents

1. Description

Some notes and references about GNU Emacs.

2. Select an area of text

Select functions with C-M-h (mark-defun).

Equivalent of Vim visual modes:

  • characterwise-visual
    1. C-x SPC runs the command rectangle-mark-mode
  • linewise-visual (blocky selection)
    1. C-a runs the command org-beginning-of-line
    2. C-SPC runs the command set-mark-command

3. Insert a literal character

C-q (quoted-insert) and " to insert a single double quote.

4. Insert a specific character

C-x 8 RET runs the command insert-char interactively, prompt for character to insert, e.g. «, », → etc.

5. List colors

List defined colors with M-x list-colors-display RET (shows the 255 colors on non-graphic frames).

6. Isearch

Search through Info pages with commands like isearch-forward or isearch-backward.

See M-x describe-function RET isearch-forward RET for a list of commands to run while searching, e.g. M-% to use query-replace.

7. Imenu

Jump to a package in list-packages with imenu bound to M-g i.

8. Narrowing

9. Kill ring

Yank (paste) from kill-ring (“clipboard”) with M-y (yank-pop)

9.1. Remove the last entry from the kill-ring

(pop kill-ring)

10. Increment numbers

Press C-M-% (query-replace-regexp) then 1 and \# as arguments to change numbers from 1 1 1 1 to 0 1 2 3.

11. Abbrevs

In Evil mode insert state C-p runs the command evil-complete-previous which use dynamic abbrevs.

12. Highlight

Highlight symbol near point with M-s h . (highlight-symbol-at-point) and M-s h u (unhighlight-regexp) to unhighlight things, see M-s h C-h for other key bindings.

13. Keyboard Macros

14. Define key bindings

  1. info “(use-package) Displaying keybindings”
  2. info “(use-package) Global keybindings”
  3. info “(emacs) Init Rebinding”
  4. info “(elisp) Low-Level Key Binding”

The bind-key.el library (used by use-package keyword :bind) adds the defined key bindings to describe-personal-keybindings (function provided by the same library) [1] [2].

The keymap.el library (provides functions like keymap-global-set) does not benefits from describe-personal-keybindings [3].

They all seems to use define-key under the hood which is a lower level function to define key bindings [4].

15. TRAMP

TRAMP extends the Emacs file name syntax by adding a remote component. A remote file name always looks like /method:user@host:/path/to/file.

15.1. File name syntax

Remote file names have method, user and host parts prepended. All of them, and also the local file name part, are optional, in case of a missing part a default value is assumed. The default value for an empty local file name part is the remote user’s home directory. The shortest remote file name is thus /-::. The - notation for the default method is used for syntactical reasons, *note info “(tramp) Default Method”.

/method:host:/path/to/file opens file /PATH/TO/FILE on the remote host HOST, using the method METHOD.

15.2. Open file on local host with sudo

Abbreviation of /sudo:root@localhost:/path/to/file (see notes:sudo).

/sudo::/path/to/file

15.3. Open file on remote host

The remote host can be the Host keyword value defined in the ssh client configuration file (see notes:ssh).

/ssh:framboise:~/file

15.4. Open file on remote host with doas

Combining methods to open a remote file as admin (see notes:doas).

/ssh:framboise|doas::/path/to/file

16. References

dim. 04 oct. 2026

Generated with Emacs 30.1 (Org mode 9.7.11)