Next: Rectangle Registers, Previous: Position Registers, Up: Registers [Contents][Index]

### 13.2 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 and later retrieve it.

`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`).

`M-x append-to-register RET r`

  Append region to text in register r.

  When register r contains text, you can use `C-x r +` (`increment-register`) to append to that register. Note that command `C-x r +` behaves differently if r contains a number. See Number Registers.

`M-x prepend-to-register RET r`

  Prepend region to text in register r.

`C-x r s r` stores a copy of the text of the region into the register named r. If the mark is inactive, Emacs first reactivates the mark where it was last set. The mark is deactivated at the end of this command. See Mark. `C-u C-x r s r`, the same command with a prefix argument, copies the text into register r and deletes the text from the buffer as well; you can think of this as moving the region text into the register.

`M-x append-to-register RET r` appends the copy of the text in the region to the text already stored in the register named r. If invoked with a prefix argument, it deletes the region after appending it to the register. The command `prepend-to-register` is similar, except that it prepends the region text to the text in the register instead of appending it.

When you are collecting text using `append-to-register` and `prepend-to-register`, you may want to separate individual collected pieces using a separator. In that case, configure a `register-separator` and store the separator text in to that register. For example, to get double newlines as text separator during the collection process, you can use the following setting.

    (setq register-separator ?+)
    (set-register register-separator "\n\n")

`C-x r i r` inserts in the buffer the text from register r. Normally it leaves point after the text and sets the mark before, without activating it. With a numeric argument, it instead puts point before the text and the mark after.

Next: Rectangle Registers, Previous: Position Registers, Up: Registers [Contents][Index]