VIM series: registers and copy and paste Buffers

Source: Internet
Author: User

VIM series: registers and copy and paste buffers can now use most of VIM's basic commands and functions to develop project code. However, during project development, we still feel that some operations are relatively inefficient. For example, we use h/j/k/l to move the cursor in a wide range. Obviously, VIM provides a more efficient command operation method. Recently, it is often necessary to copy, paste, search, and replace codes. Common d/y/x/p commands are not enough, so I learned about the VIM register function. Using the content buffer function of the Register can greatly improve the efficiency of copying and pasting a lot. The Register Type VIM contains 9 type registers. The main function of the Register is to delete, copy, search, and other text content during the cache operation: the help registers command is used to view Detailed help descriptions of registers. Here, the type is translated as follows: untitled register "" -- the default register used by vim. The text source command is as follows: d/c/s/x/y10 digit naming register "0-" 9 -- vim caches the text generated by the yank and delete row operation commands and one non-row deletion content caching register "--- the 26-letter naming register "a-" z/"A-" Z-"z generated when the vim cache delete operation is not on the line -- four read-only registers completely specified by the user". "%" # ": expression register" = -- use VIM's powerful expression function (never used, never understood) GUI to select register "*" + "~ -- Vim caches the selected text black hole register in the GUI "_ -- similar to the/dev/null file in Linux, it can only be input, it can be used to filter out the last search mode register that affects the default register "/-- there are many registers for the last search content cached in vim. How can we view their content? Use the VIM: registers command or the short: dis command to list the contents of all existing registers. Then you can choose to paste the content of the specified register. Register use notice that the above register name has a double quotation mark (double quotation mark), which is their method. When operating commands such as d/y/x in Normal mode, add the register name such as "ayy" before the command to put the content generated by the command into the specified register, in register a above, rather than the "" register and "0 register used by vim by default. When pasting, add the register name such as "ap" to the front of the p command to put the content in the register on the top or bottom of the row where the cursor is located. The read-only registers and the search mode registers are put by VIM. Users can only use their content. The following describes some registers that I think will be useful and familiar with during development. Digit register "0: stores the text content generated by the most recently used y command. If its content is not explicitly specified" 1-"9: store the text content generated by the recently used d-line operation command. if the content is not explicitly specified and the content is stored in turn between the nine registers, when there is new content, push "1 content to" 2, 2 to 3, 3 to 4... letter register if you want to copy a paragraph of content multiple times back and forth for a long time, it is best to use the letter register, because their content will not be automatically modified by VIM after you modify it, the content of the number register will overwrite the content you specified with the use of new operations. "A-" z: each time you specify these registers, the generated text will overwrite the original content in the register. "A-" Z: each time you specify these registers, after the generated text content is appended to the original content in the register, if the value of the 'cpopexception' option has a> symbol, the line is split when appending. You can run the following command :: set cpo ++ => Settings. Read-only register ".: contains the text content last inserted in vim insert mode. You can also use the command to repeat the previous operation. "%: Contains the name of the current file to facilitate the insertion of the file name" #: contains the currently available file name, the name of the file used in the current session. When the system clipboard copies content between multiple applications in the system, it is used to the system clipboard, which can be "*, "+ registers to paste the content into VIM. They are also read-only registers. In addition, you can also use the keyboard shortcut Shift + Insert to quickly Insert data. Besides adding a register number before the operation command to specify the register content, vim also provides the command to explicitly specify the register content in the command line: let -@, for example, Run let @ a = "vim registers blog" to set the "a register content to the right. In vim, you can use the command set paste to set the paste mode status. In this case, the pasted content will remain unchanged in the original format. Run the command set nopaste to return to the normal operation mode.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.