Emacs as Word Processor: Selection

Before copying or cutting, the normal thing to do is to select a region for it. Here are some of the relevant commands and configuration options.

The keybind C-space sets the mark in Emacs’ terminology. That is, it initiates selection that can be expanded into a region by moving the point by ordinary movement keys. The movement keys are left and right arrows to move per character, C-left and C-right or M-f and M-b to move by word, up and down arrows to move by line, C-up and C-down by paragraph. If the mark is first set, these movement keys expand and contract the region accordingly.

The keybind to select a word (to the end, not to the beginning when in the middle of it) is M-@. Pressing it multiple times selects more following words one by one. By default, Shift+movement-keybinds should also work for selection, even though in terminal emulators one might run into issues. For example, Control-Shift-left should select words towards the beginning and pressing the combination multiple times extends the selection.

The keybind to select a full paragraph is M-h. Pressing it multiple times selects more following paragraphs. Pressing M-h on a heading selects the heading and its entire contents in Org mode.

To copy the selected region, the default keybind is M-w. Cut works by C-w. These keybinds save the copied or cut region for a later pasting. To delete the selected region without preserving it, use the Delete key. Undo is keybound to C-x u.

In most (nearly all) editors (and word processors), the region is automatically deleted when typing over the region. This behaviour can be obtained in Emacs by putting the following in Emacs’ main config:

(delete-selection-mode t)

Leave a Reply

Your email address will not be published. Required fields are marked *