Using Registers

Registers let you store and restore strings, integers (with increments), rectangles, file and directory paths, WindowConfigurations, FrameConfigurations, and markers very quickly.

Basic Register functions

C-x r s RCopy the region into register R
C-x r r RCopy the region-rectangle into register R
C-x r SPC RSave the position of point (and the name of the current buffer) into register R
C-x r f RCopy the frame configuration into register R
C-x r w RCopy the window configuration into register R

R is the register name that you choose, consisting of a single character. Register names are case-sensitive.

For example, to copy the current region to a register you name 1, use ‘C-x r s 1’. To insert the contents of that register at point, use ‘C-x r i 1’.

Storing Numbers in Registers

Example use of storing number in registers:

C-u 1000 C-x r n x Store 1000 in register x.

C-x r i x – Insert the number in register x into the buffer.

C-x r + x – Increment the number by one.

See the Node Keeping Numbers in Registers in the EmacsManual.

NumbersInRegisters can also be put to good use in KeyboardMacros.

Register Tips

          (set-register ?e '(file . "~/.emacs"))
          (set-register ?i '(file . "~/org/"))

Extending Registers

Lisp:list-register.el fails for me because of ‘truncate-string’ not being defined here in Emacs 23 (CVS). I would be glad to test this library, of course.) – BastienGuerry

Register Keybindings Overview

text register
C-x r s astore region as “a”
C-x r i ainsert region stored in “a”
C-x r r astore rectangle as “a”
point register
C-x r SPC astore current point as “a”
C-x r j amove to point in “a”
window register
C-x r w astore configuration of windows in frame
C-x r j arestore window configurations
frame register
C-x r f astore window configuration for all frames
C-x r j arestore all window configurations
number register
C-u 1 C-x r n astore 1 in “a”
C-u 1 C-x r + aadd 1 to number in “a”
C-x r i ainsert number in “a”
position register
C-x r m RETsave default
C-x r m <NAME> RETsave as NAME
C-x r b RETmove to default
C-x r b <NAME> RETmove to NAME
C-x r llist

CategoryEditing CategoryRegion