1.2. Editing Files
1.2.1. Working in Text Mode
Text mode is the standard mode for typing text. By default, Emacs does not do word wrap, instead creating very long lines. To enable word wrap, type ESC x auto-fill-mode RETURN.
You may decide that you want to enter auto-fill mode automatically whenever you edit. If so, add this line to the Emacs startup file, .emacs, which is located in your home directory. (If the startup file doesn't exist, create it.)
(setq default-major-mode 'text-mode) (add-hook 'text-mode-hook 'turn-on-auto-fill)
1.2.2. Moving the Cursor
To move | Keystrokes Command Name |
---|---|
Forward one character | C-f forward-char |
Backward one character | C-b backward-char |
Up one line | C-p previous-line |
Down one line (at the end of a file, creates a newline) | C-n next-line |
Forward one word | ESC f forward-word |
Backward one word | ESC b backward-word |
To the beginning of the line | C-a beginning-of-line |
To the end of the line | C-e end-of-line |
Forward one screen | C-v scroll-up |
Backward one screen | ESC v scroll-down |
To the beginning of the file | ESC < beginning-of-buffer |
To the end of the file | ESC > end-of-buffer |
1.2.3. Repeating Commands
To | Keystrokes Command Name |
---|---|
Repeat the following command n times | ESC n digit-argument |
Repeat the following command 4 times | C-u universal-argument |
Repeat the following command 16 times | C-u C-u universal-argument |
Repeat a complex command (can edit arguments) | C-x ESC ESC repeat-complex- command |
Recall previous command ... |
Get GNU Emacs Pocket Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.