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-visualC-x SPCruns the commandrectangle-mark-mode
linewise-visual(blocky selection)C-aruns the commandorg-beginning-of-lineC-SPCruns the commandset-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
- info “(use-package) Displaying keybindings”
- info “(use-package) Global keybindings”
- info “(emacs) Init Rebinding”
- 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,userandhostparts 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