Accessing Registers


Now that we have learned how to yank text into a named register and review register contents, lets see how to retrieve values from registers.

Similar to the pattern for yanking text into a register, the pattern for accessing text in a register is:

"{name}

So, to paste the contents of register a into the buffer we would execute "ap.

To demonstrate, consider the following buffer and cursor position.

Initial buffer content
Beautiful·is·better·than·ugly.
Explicit·is·better·than·implicit.
Simple·is·better·than·complex.
Complex·is·better·than·complicated.
NORMALTop1:1
 

Our goal is to move the first line to the bottom of the buffer. We will accomplish this in a few steps. First, we will enter visual-line mode using V, then delete the selection and store it in register a using "ad:

Select and delete lineV"ad
Explicit·is·better·than·implicit.
Simple·is·better·than·complex.
Complex·is·better·than·complicated.
NORMALTop1:1
 

Now move the cursor to the bottom of the buffer using G

Move to bottom of bufferG
Explicit·is·better·than·implicit.
Simple·is·better·than·complex.
Complex·is·better·than·complicated.
NORMAL75%3:1
 

and finally paste from register a:

Paste from register a"ap
Explicit·is·better·than·implicit.
Simple·is·better·than·complex.
Complex·is·better·than·complicated.
Beautiful·is·better·than·ugly.
NORMAL80%4:1