Wednesday, July 29, 2009

Types of Registers

There was some mention of the special registers in Vim in the comments on my last post. Here's a list of all available registers in Vim (copied directly from the docs). For more info on what these registers do, please see :help registers.

There are nine 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. four read-only registers ":, "., "% and "#
6. the expression register "=
7. The selection and drop registers "*, "+ and "~
8. The black hole register "_
9. Last search pattern register "/

5 comments:

freegnu said...

You can also insert the word the cursor is in on the ex command line with Ctrl-R Ctrl-W.

Tomasz said...

thanks bunches, man..
been going around with vim for two or three years, but i keep learning new things every day ;). the _dd and _x are actually something i've been looking for some time already, just had no idea that it's called 'blackhole' =)

dot SEO said...

Its sounds just great, i do like freegnu says :-)

McFiredrill said...

are these the same as "buffers"??

Travis Whitton said...

@McFiredrill

No, buffers are the mechanism that Vim uses to store a file. A window (what you see when using Vim), is a viewport into a buffer. You can have many buffers loaded at once and switch between them with :buff # (where # is the buffer you want). Just typing :buffers will give you a list of what's currently loaded.

Registers are the locations that Vim stores deleted or yanked text. Typical registers range from a-z and A-Z, but there are a number of registers that fall outside of the named registers and serve special functions. See :help registers for the full story.

HTH,
Travis