(setq plaintext 'everywhere)



The Basic Key Bindings Of Emacs

Table of Contents

[2023-01-31 Tue]

This is a summary of most of the Emacs key bindings that can be found in the Emacs tutorial. You can start the tutorial inside Emacs with C-h t. The tutorial covers the basics of movement, editing, window and buffer management and much more. The most important key binding to remember is M-x; to get access to all of Emacs' commands.

1 Buffer movement

Key binding Function Notes
C-v scroll-up-command Scroll the window up a full screen
M-v scroll-down-command Scroll the window down a full window
C-l recenter-top-bottom Center the buffer around the cursor

2 Cursor movement

Key binding Function Notes
C-f forward-char Move the cursor forward one character
C-b backward-char Move the cursor backward one character
C-p previous-line Move the cursor to the previous line
C-n next-line Move the cursor to the next line
M-f forward-word Move the cursor forward one word
M-b backward-word Move the cursor backward one word
C-a move-beginning-of-line Move the cursor to the beginning of the line
C-e move-end-of-line Move the cursor to the end of the line
M-a backward-sentence Move the cursor backwards one sentence
M-e forward-sentence Move the cursor forwards one sentence
M-< beginning-of-buffer Move to the beginning of the buffer
M-> end-of-buffer Move to the end of the buffer

3 Universal argument

To supply an emacs command a numeric argument, the repeat count or prefix argument, prefix it with C-u and then the digits before you type the command. Alternatively hold Meta will typing the digits. For example C-u 15 C-f moves the cursor 15 characters forward. Negative are also possible e.g. C-u -15 C-f to move backwards 15 characters.

The universal argument also work on regular characters, e.g. C-u 8 * results in ********.

4 Quit

To quit in the middle of typing a key cord use C-g. It can also be used when Emacs stops responding.

5 Windows

Windows are where 8 are shown. You can have multiple windows in a single frame (see 10 for more information) and you can also have the same buffer open in multiple windows.

Key binding Function Notes
C-x 1 delete-other-windows delete all windows except the focussed window
C-x 2 split-window-below create a new window below
C-x 3 split-window-right create a new window to the right
C-x o other-window change focus to another window
C-M-v scroll-other-window a negative prefix scrolls the other way C-u -

6 Editing

6.1 Killing, Deleting and Yanking

Key binding Function Notes
<DEL> kill-backward-char <DEL> := backspace
C-d delete-char delete character under the cursor
M-<DEL> backward-kill-word kill the word before the cursor
M-d kill-word kill the word after the cursor
C-k kill-line kill the line after the cursor
M-k kill-sentence kill the sentence after the cursor
     
C-w kill-region  
     
C-y yank 'paste' text from the kill ring
M-y yank-pop search the kill ring by repeatedly pressing M-y

6.2 Undo-ing

C-/, C-_ and C-x u can be used to undo. In order to redo (i.e. undo your undos) you must 'push' your undos to the undo-ring. You do this by pressing C-g (or any movement such as C-f) and then use C-/ (or one of the other undo commands) to undo your undos.

Key binding Function Notes
C-/, C-_, C-x u undo undo any edit

7 Files

Key binding Function Notes
C-x C-f find-file open a file for editing
C-x C-s save-buffer save the file

Note that the file (and the directory it lives in) opened with C-x C-f does not need to exist. Once you save the file, C-x C-s Emacs will create the file and directories if necessary.

8 Buffers

A buffer is where Emacs stores the text contained in a file or the messages shown in the minibuffer (called the *Messages*) or any other piece of text. A buffer will remain accessible within Emacs until you M-x kill-emacs or you M-x kill-buffer the buffer.

Key binding Function Notes
C-x C-b list-buffers open a buffer listing all buffers
C-x b switch-to-buffer switch to a buffer
C-x s save-some-buffers interactively save open buffers

9 Searching

Key binding Function Notes
C-s isearch-forward incrementally search forward
C-r isearch-backward incrementally search backward

10 Frames

An Emacs frame is what most people would call a window.

Key binding Function Notes
C-x 5 2 make-frame-command creates a new frame
C-x 5 0 delete-frame  

11 Recursive Editing

Recursive editing is a topic in itself but recursive editing is indicated by the [] around the major mode on the mode line e.g. [(Fundamental)] instead of (Fundamental).

Key binding Function Notes
<ESC> <ESC> <ESC> keyboard-escape-quit leave recursive editing level

12 Getting Help From Emacs

The describe-* functions are really useful when you are hacking on your emacs.

Key binding Function Notes
C-h c describe-key-briefly Show the function ran by a keybinding in the message buffer
C-h k describe-key Display more info on a keybinding
C-h x describe-command Display help buffer for a command
C-h a apropos-command List all command containing a KEY word
C-h v describe-variable  
C-h f describe-function  


If something is not working, please create an issue here.