Skip to main content

13 Registers

Emacs registers are compartments where you can save text, rectangles, positions, and other things for later use. Once you save text or a rectangle in a register, you can copy it into the buffer once or many times; once you save a position in a register, you can jump back to that position once or many times.

Each register has a name that consists of a single character, which we will denote by r; r can be a letter (such as β€˜a’) or a number (such as β€˜1’); case matters, so register β€˜a’ is not the same as register β€˜A’. You can also set a register in non-alphanumeric characters, for instance β€˜*’ or β€˜C-d’. Note, it’s not possible to set a register in β€˜C-g’ or β€˜ESC’, because these keys are reserved for quitting (see Quitting).

A register can store a position, a piece of text, a rectangle, a number, a window configuration, or a file name, but only one thing at any given time. Whatever you store in a register remains there until you store something else in that register. To see what register r contains, use M-x view-register:

M-x view-register RET r​

Display a description of what register r contains.

All of the commands that prompt for a register will display a preview window that lists the existing registers (if there are any) after a short delay. To change the length of the delay, customize register-preview-delay. To prevent this display, set that option to nil. You can explicitly request a preview window by pressing C-h or F1.

Bookmarks record files and positions in them, so you can return to those positions when you look at the file again. Bookmarks are similar in spirit to registers, so they are also documented in this chapter.

β€’ Position RegistersΒ Β Saving positions in registers.
β€’ Text RegistersΒ Β Saving text in registers.
β€’ Rectangle RegistersΒ Β Saving rectangles in registers.
β€’ Configuration RegistersΒ Β Saving window configurations in registers.
β€’ Number RegistersΒ Β Numbers in registers.
β€’ File RegistersΒ Β File names in registers.
β€’ Keyboard Macro RegistersΒ Β Keyboard macros in registers.
β€’ BookmarksΒ Β Bookmarks are like registers, but persistent.