O'Reilly logo

GNU Emacs Pocket Reference by Debra Cameron

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required