Vim provides many registers. We can use these registers as multiple clipboards. This feature is really useful while working with multiple files. In this chapter, we will discuss following items −
For copying, we can use normal yank command i.e. yy and to store it in register we can use following syntax −
“<register-name><command>
For instance, to copy text in register “a” use following command −
“ayy
To paste text from register use −
“<register-name>p
For instance, below command copies text from register “a” −
“ap
To list all available registers use following command
:registers
Vim supports following types of registers −
Unnamed register is denoted by “”. Vim stores deleted or copied text in this register
We can use 26 named registers; we can use a-z or A-Z. By default vim doesn’t uses these registers.
If we use lower case register name then contents will be overwritten and if we use uppercase name then contents will be appended in that register.
We can use 0 to 9 named registers. Vim fills these registers with text from yank and delete command.
Following are the default registers −
Sr.No | Register & Description |
---|---|
1 | %
Name of the current file |
2 | #
Name of the alternate file for the current window |
3 | :
Most recently executed command |
4 | .
Contains the last inserted text |
5 | “
Last used register |