Go to the end to see the summary
Introducing Vim registers
Vim documentation says:
There are ten types of registers: 1. The unnamed register "" 2. 10 numbered registers "0 to "9 3. The small delete register "- 4. 26 named registers "a to "z or "A to "Z 5. Three read-only registers ":, "., "% 6. Alternate buffer register "# 7. The expression register "= 8. The selection registers "* and "+ 9. The black hole register "_ 10. Last search pattern register "/
It may seem a lot, (and indeed the documentation for registers in Vim is a bit
complicated for my taste) and one may not use them all (at least not all the
time), but I'll try to describe them here in simple words. Of course I'll
leave a lot of functionality and corner cases out of this description. For
Remember that to interact with them you usually use
" plus the name of the
"ad deletes to register
"a). On Vim scripts, you can refer
to them (for read and write if allowed) with
:let @a = "foo")
You can see the contents of all the registers with
The unnamed register
This is the one you're already using all the time, for deleting and yanking. Everything goes here, no matter what it is, all the time (more or less, check docs for details). That's why you get frustrated when you copy something and then delete a character and override your copied text.
This is the register that is invoked if you do not specify a register.
So things like
y go into here, and things like
content from here.
The numbered registers
Those are of 2 types really:
"0Any yank command goes here (and to
""too) unless you specify another registry.
"9Any delete or change command goes here unless you specify another register or the change is "small" (less than one line). This works like a queue, when you delete again, goes to
"1and what was in
"2, what was on
"3... until what was on
"9gets discarded. So you have some sort of "delete history"
The small delete register
Here go all the delete operations less than one line long unless other register specified.
They are not automatically populated. You can use them explicitly to have 26 "clipboards" if you like. Keep in mind that they are shared with the macros. When addressed upper-case, they append the content to the register instead of replacing it.
Useful for reorganizing blocs too, you just append blocs of text to one register in the order you want and then paste it in the place you want it to be.
".Last inserted text. Just like the "dot" command.
"%Name of the current file.
"Most recent command line.
Alternate file register
Contains the name of the alternate file (
CTRL-^), the one marked
This is not a register like the others. It allows you to execute an expression
that is converted to a string and put in place with
p or automatically if you
are in insert mode and invoke it with
Those are your system clipboards. Vim has to be compiled with support for this. One is the primary and the other is the clipboard (X11 stuff, you know). I never remember which is which, so I have some aliases like this:
" copy and paste from system easily if has("mac") nnoremap cp "*p xnoremap cy "*y else nnoremap cp "+p xnoremap cy "+y endif
Black hole register
This is like sending stuff to
The last search pattern register
Contains the most recent search pattern. Not sure of its utility, but it's there.
- If you do not specify a register,
""(the unnamed register) is used.
- Your last copy is always available at
- A "delete history" is available on
- Less than one line deletions are available on
- There are 26 "clipboards" in Vim (
"z) that can be appended addressing them upper-case.
- You can evaluate expressions (like basic arithmetic and more) with the
- Interacting to and from the system clipboard is possible with the selection registers.
- If you have something sensible that want to delete, use the black hole
- You can check the contents of all the registers with
Hope it helps, and I hope I do not forget now.
Have any comments ? Send an email to the comments address.