There are ten types of registers:
- Unnamed register “”
- Numbered registers “0 to “9
- Small delete register “-
- Named registers “a to “z or “A to “Z
- Read-only registers “:, “., “%
- Alternate buffer register “# (neovim considers it as RO reg)
- Expression register “=
- Selection and drop registers “*, “+ and “~
- Black hole register “_
- Last search pattern register “/
unnamed register “”
Vim uses unnamed register as the default register.It used for all delete , change , copy , cut operations also It points to the last used register unless last used register is Black hole reg.you use it very often. Whenever you use y/Y or p/P commands , you are using unnamed register.It is still surprising to see name for an unnamed register.It can explicitly accessed using “” in normal mode or ” in insert mode
Numbered registers “0 to “9
Vim gradually fills up these registers as you keep using delete and copy(yank) commands.So what do I mean by that , with each successive deletion or change, Vim shifts the previous contents of reg 1 into reg 2, 2 into 3, and so forth, losing the previous contents of reg 9.
- reg 0 contains most recently yanked text
- reg 1 contains most recently deleted text
Small delete register “-
This register contains text from commands that delete less than one line, except when the command specifies a register
Named registers “a to “z or “A to “Z
These register are like your treasury ,they only be filled or used only when you specifically order VIM. Text can easily appended to these registers.You use small-caps to overwrite previous text if any and Upper case to append to existing text. Uses
Read-only registers “:, “., “%
We have 3 Read-Only regs,you can only use them on 3 variants of one command.How co-incidental.p,P,:put are the only privileged commands known to have access rights to read-only regs.
"./(dot command /) Everyone who have used VIM for more than a week know what I am talking about.dot repeats last insert operation.
":Stores most recent command line command.if you are curious to see its contents, use
<c-r>:in normal.one more trick,used @: to repeat last command.
"%Stores current file name, a very unusual feature that I missed in every editor I used other than VIM.
Alternate buffer register “#
This comes in play when you have more than one file opened in VIM.Stores name of the alternate file for the current window.It will change how the
<c-^>command works. This register is writable in VIM but read-only in NEOVIM.
Expression register “=
I call this one as built-in calculator that is bundled with VIM, again a feature that I miss in other editors and IDE’s I use.This is not really a register that stores text, but is a way to use an expression in commands which use a register.This is one of those register with its own special history.It is a little tricky to use, but once you get the hang of it,your productivity will get a pretty decent boast.To access it hit = after
<c-r> in insert mode or ” in normal mode, doing so will drop me on command line,I now have all the power command line has to offer.
Selection and drop registers “*, “+ and “~
Stores and retrieves the selected text from the GUI.
"*Holds text copied to system clipboard, if VIM has this feature enabled
"+This is synonymous with * under windows but distinct in Unix(x-11) based systems
"~People familiar with unix based systems may think of this one as home directory for current user.It is read-only register, strange right.I wonder why it is not included in Read-only reg list.Register stores the dropped text from the last drag’n’ drop operation. When something has been dropped onto Vim, this reg is filled in and the pseudo key is sent for notification.It is highly possible that you are ever gonna use it.
Black hole register “_
It is what it say, anything sent to it is lost forever.*nix user can think of it as
/dev/null.Cool awesome example, just popped up at perfect moment.
Last search pattern register “/
Here come one more extremely useful register,ever wondered how vim could remember tons of your searches. It is a RW register value can be assigned using let Vim script anyone.
We will wrap up now.Before we do here are few commands that can help you use register better.
:reg :dis :help registers :help quote_quote :help quotenumber :help quote- :help quote- :help quotealpha :help quote. :help quote% :help quote: :help *quote# :help quote= :help quote~ :help quote= :help quote :help quote/ :help @/