Links: Vim

A register is something like a clipboard or a container where you store text. You can access any register by using a double quote before its name, for example for register a with “a.
You can add and print text from a register with the yank and paste commands. To add text to a use “ay and to print it “ap.

To see the content of all the used registers you can use to command :reg or :register, you’ll notice that there
are quite a lot of things going on.

You can also paste the content form any register while in Insert mode by pressing Ctrl-r followed by the register.

Yank, delete and numbered registers

Every time you copy or delete something this would go to the register, which is the default when pasting (""p is the same as p), but only yanking text gets saved on the 0 register by default.
You could access the last copied text with “0p even after deleting something after.

Both deleted and yanked text gets saved in order in the other number registers, so the last
yanked text is on 1, the previous one is on 2, the one before in 3 and so on.

Tip

You may have noticed that if you copy something and then delete some text, when you go to paste it, you would have the deleted text instead of what you copied. This can be solved thanks to registers.

Read only registers and search register

There are 4 read only registers, where the next information is saved:

registerdescription
.last inserted text
%current file path
:last executed command
#last edited file

This isn’t read only, but the last text you search will end up on the / register, as expected.

Alphabetic registers and macros

Macros are just strings of text saved on a register, and the @ executes whatever is inside of them, you could save anything inside of those registers and even record macros without executing them before.

With the command :let you can enter text directly inside a register like :let @a='hello'.

Note

Registers a and A are the same, but if you write on register A you’ll be appending text to a instead of overwriting it.

Other registers

registerdescription
=last evaluated expression
/last search
+The system’s clipboard
_(void) all text pasted here will be deleted forever