Register Basics

If you have experience working with other editors, you are probably familiar with copying some text to the clipboard then pasting it from the clipboard back into the document in another location. In most editors, "the clipboard" stores bits of text in memory so they can be accessed later. Most editors also only allow one piece of text to be stored at any time, so that text that is copied replaces any text in the clipboard.

In Vim, the clipboard concept is called "registers", and their basic usage is similar to the previous example: "yank" selected text by pressing y, then move the cursor to another location and press p to paste it back into the document.

Technically, this usage describes Vim's "unnamed register", which is automatically populated with any text that is yanked or deleted (using d, c, x, etc).

As a brief example, given the following buffer we can yank the current line by executing the ["x]yy command:

Yank the current line
yy
Beautiful·is·better·than·ugly.
Explicit·is·better·than·implicit.
Simple·is·better·than·complex.
Complex·is·better·than·complicated.
NORMAL
Top
1:1
 

then review the buffer contents by executing :registers

View the Registers
Beautiful·is·better·than·ugly.
Explicit·is·better·than·implicit.
Simple·is·better·than·complex.
Complex·is·better·than·complicated.
NORMAL
Top
1:1
 
:reg
Type Name Content
  l  ""   Beautiful is better than ugly.
  l  "0   Beautiful is better than ugly.

The contents of the unnamed register are shown on the top line, where the empty quotes in the name column identity it as the "unnamed" register.