Vim copy and paste and register
Vim copy and paste and register
Temporary content for operations such as copying, deleting, and replacing in Vim will be stored in registers.
1. Unknown register ("")
Two double quotes. Vim is called an anonymous register. For operations such as x, s, d, c, and y, if no register is specified, the temporary content is put into this register, which is equivalent to a default register.
You can use reg to view the value of the current Register, perform operations, and check the register content.
For example:
Copy the current row (yy) and paste it (p ).
Here, the y command will put the content of the current line into the Register "". When you press p, the content will be retrieved from the Register.
2. Copy a dedicated register ("0)
Content copied using the y command is saved to register 0.
The register is used by "following the register name.
For example:
Copy the current row (yy ),
Several more word deletion operations (dw) were performed)
However, if you only want to paste the copied row, you cannot paste it with the anonymous register ". You cannot paste the row directly with p. You need to use" 0 p to specify the register 0, because "0" only stores the content saved by the y command.
3. delete a special register ("1-" 9)
The content deleted through the d or c command will be saved in the nine registers "1-" 9.
The latest deleted content will be in "1, and the other will be postponed.
For example:
Delete current row (yy)
Delete current row (yy)
To copy the row deleted for the first time, "2 p
4. Name Register ("a-" z)
You can put important content in the Name Register "a-" z, a total of 26.
For example:
Put the current row in register "j," jyy
Copy register "j content," jp
5. Black Hole register ("_ d)
The content put in this register will not be put in any other register, which is equivalent to completely deleting the content.
For example:
Delete the current row permanently without adding any registers, "_ dd
6. System clipboard ("+)
Through the "+ register, you can copy the content to the system clipboard, or paste the content from the system clipboard but Vim.
For example:
Copy the current row to the system clipboard, "+ yy
Copy the system clipboard to vim, "+ p
To use a register
[Double quotation marks] [Register name] [command]
For more Vim tutorials, see the following:
Build VIM into a simple and practical IDE
Vim Learning Guide
Quick learn Vi Editor
Powerful Vim Editor
Build a Vim Development Environment on CentOS 6.2
Install the highlighted Vim editing tool in CentOS 5.4
Vim tips: C language settings
Set the Vim row number in Ubuntu
Vim editor basic tutorial
This article permanently updates the link address: