Go to the previous, next section.

Registers

Emacs registers are places you can save text or positions for later use. Text saved in a register can be copied into the buffer once or many times; a position saved in a register is used by moving point to that position. Rectangles can also be copied into and out of registers (see section Rectangles).

Each register has a name, which is a single character. A register can store either a piece of text or a position or a rectangle, but only one thing at any given time. Whatever you store in a register remains there until you store something else in that register.

M-x view-register RET r
Display a description of what register r contains.

M-x view-register reads a register name as an argument and then displays the contents of the specified register.

Saving Positions in Registers

Saving a position records a spot in a buffer so that you can move back there later. Moving to a saved position reselects the buffer and moves point to the spot.

C-x / r
Save location of point in register r (point-to-register).
C-x j r
Jump to the location saved in register r (register-to-point).

To save the current location of point in a register, choose a name r and type C-x / r. The register r retains the location thus saved until you store something else in that register.

The command C-x j r moves point to the location recorded in register r. The register is not affected; it continues to record the same location. You can jump to the same position using the same register any number of times.

Saving Text in Registers

When you want to insert a copy of the same piece of text frequently, it may be impractical to use the kill ring, since each subsequent kill moves the piece of text further down on the ring. It becomes hard to keep track of what argument is needed to retrieve the same text with C-y. An alternative is to store the text in a register with C-x x (copy-to-register) and then retrieve it with C-x g (insert-register).

C-x x r
Copy region into register r (copy-to-register).
C-x g r
Insert text contents of register r (insert-register).

C-x x r stores a copy of the text of the region into the register named r. Given a numeric argument, C-x x deletes the text from the buffer as well.

C-x g r inserts in the buffer the text from register r. Normally it leaves point before the text and places the mark after, but with a numeric argument it puts point after the text and the mark before.

Saving Rectangles in Registers

A register can contain a rectangle instead of linear text. The rectangle is represented as a list of strings. See section Rectangles, for basic information on rectangles and how rectangles in the buffer are specified.

C-x r r
Copy the region-rectangle into register r (copy-region-to-rectangle). With numeric argument, delete it as well.
C-x g r
Insert the rectangle stored in register r (if it contains a rectangle) (insert-register).

The C-x g command inserts linear text if the register contains that, or inserts a rectangle if the register contains one.

Go to the previous, next section.