Registers
*********

Emacs registers are places you can save text or positions for later use.  Text and rectangles saved in registers can be copied into the buffer once or many times; you can move point to a position saved in a register.

Each register has a name which is a single character.  A register can store a piece of text, a rectangle, a position, 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 a register R contains, use M-x view-register.

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

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 that buffer and moves point to that spot.

C-x r SPC R
     Save position of point in register R (point-to-register).

C-x r j R
     Jump to the position saved in register R (jump-to-register).

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

The command C-x r j R moves point to the position recorded in register R.  The register is not affected; it continues to record the same position.  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 several times, it may be inconvenient to yank it from the kill ring, since each subsequent kill moves that entry further down the ring.  An alternative is to store the text in a register with C-x r s (copy-to-register) and then retrieve it with C-x r i (insert-register).

C-x r s R
     Copy region into register R (copy-to-register).

C-x r i R
     Insert text from register R (insert-register).

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

C-x r i 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 (C-u) 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 Rectangles, for basic information on how to specify a rectangle in the buffer.

C-x r r R
     Copy the region-rectangle into register R (copy-region-to-rectangle).  With numeric argument, delete it as well.

C-x r i R
     Insert the rectangle stored in register R (if it contains a rectangle) (insert-register).

The C-x r i R command inserts a text string if the register contains one, and inserts a rectangle if the register contains one.

Saving Window Configurations in Registers
=========================================

You can save the window configuration of the selected frame in a register, or even the configuration of all frames, and restore the configuration later.

C-x r w R
     Save the state of the selected frame's windows in register R (window-configuration-to-register).

C-x r f R
     Save the state of all windows in all frames in register R (frame-configuration-to-register).

Use C-x r j R to restore a window or frame configuration. This is the same command used to restore a cursor position.  When you restore a frame configuration, any existing frames not included in the configuration become invisible.  If you wish to delete these frames instead, use C-u C-x r j R.

Keeping File Names in Registers
===============================

If you visit certain file names frequently, you can visit them more conveniently if you put their names in registers.  Here's the Lisp code used to put a file name in a register:

     (set-register ?R '(file . NAME))

For example,

     (set-register ?z '(file . "/gd/gnu/emacs/19.0/src/ChangeLog"))

puts the file name shown in register z.

To visit the file whose name is in register R, type C-x r j R.  (This is the same command used to jump to a position or restore a frame configuration.)