This page looks best with JavaScript enabled

Registers in VIM-NEOVIM

 ·  ☕ 4 min read  ·  ✍️ Syed Dawood

Unnamed "

Vim uses unnamed register as the default register. It is often used for all delete, change, copy or cut operations. It also points to the last used register unless last used register is Black hole register. 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 be explicitly accessed using "" in normal mode or " in insert mode

Numbered 0 to 9

Vim gradually fills up these registers as you keep using delete and copy(yank) commands. This means 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 -

This register contains text from commands that delete less than one line, except when the command specifies a register

Named a to z / A to Z

These registers are like your treasury. They will only be filled or used when you specifically order VIM. Text can be easily appended to these registers.You use small-caps to overwrite previous text if any, and Upper case to append to existing text.

Read-only : , . and %

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 register.

  • . dot
    Anyone who have used VIM for more than a week know what I am talking about. dot repeats last insert operation.

  • : colon
    Stores most recent command line command. If you are curious to see its contents, use <c-r>: in normal mode.one more trick,use @: to repeat last command.

  • % Percentile
    A very unusual feature that I missed in every editor I used other than VIM.

Alternate buffer #

This comes in play when you have more than one file open 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 =

I call this one the poor mans repl 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. 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 *, + , ~

Stores and retrieves the selected text from the GUI.

  • "/ Holds text copied to system clipboard, if you VIM installation has this feature enabled.

  • "+ This is synonymous with * under windows but distinct in Unix(x-11) based systems.

  • "~ People familiar with *nix 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 registers 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 unlikely that you are ever gonna use it.

Black hole _

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 /

Here come one more extremely useful register, ever wondered how vim could remember tons of your searches. It is a Read-Write register. Its value can be manipulated using let. Vim script anyone.

Conclusion

We will wrap up now.Before we do here are few commands that can help you understand and use register better.

   :reg
   :dis
   :help registers
   :help quote_quote
   :help quote_number
   :help quote_-
   :help quote-
   :help quote_alpha
   :help quote_.
   :help quote_%
   :help quote_:
   :help *quote_#
   :help quote_=
   :help quote_~
   :help quote_=
   :help quote_
   :help quote_/
   :help @/
Share on

ALLSYED
WRITTEN BY
Syed Dawood
< frontend | backend | fullstack > Developer