If you haven’t done so already, I’d recommend reading the section on “buffers” first. Registers are very similar to buffers they’re just accessed a bit differently.
The Yank & Delete Registers
(The rolling clipboard)
When you delete lines of text you are also pushing them onto a stack of 9 numbered registers. Think of it as a rolling clipboard containing the last 9 items.
You can put any of the last 9
yanks or deletions into the current text by saying
<num> is the number of the register you want to paste. E.g.
"1p to paste the last thing you deleted (equivalent to
"2p for the
one before that. This is, of course, pretty much useless for normal humans who
don’t memorize the order they deleted things and then number those memories.
Fortunately there is useful, and memorable way to work with multiple named
registers. Vim lets you name your registers whatever you want… as long as the name
is one of the 26 letters in the English alphabet. ;) To
delete into a
named register you precede your
d command with a double quote (
" is the comment character in VimScript, and yes that’s very odd.
If you wanted to
yank the current line into register
c you would say
Unfortunately, the position of the number is reversed compared to normal
yanking. Normally, to
yank the current line and the next 2 you’d say
yank the current line, and the next 2 after it into the
you would say
Listing registers is pretty simple. Just type
:registers. You can also filter
it to just the ones you want. If you had been using
c as named
registers you could say
:register a b c and it would just show you those.
Getting Stuff Out of Registers
As mentioned above, you
put it. If you wanted to
put the thing in
register 9 you’d
"9p. If you wanted to
put the thing in register
"zp. Note that I’m not prefacing those with
:. You have to type this blind.
Stuff you’ll probably never need to know
(but will explain some of the items you see when you run
There are ten types of registers:
- The unnamed register “”
- 10 numbered registers “0 to “9
- The small delete register “-
- 26 named registers “a to “z or “A to “Z
- three read-only registers “:, “., “%
- alternate buffer register “#
- the expression register “=
- The selection and drop registers “*, “+ and “~
- The black hole register “_
- Last search pattern register “/
:help registers for more details.