How to use VIM recording

Source: Internet
Author: User
When using vim to accidentally touch the Q key, the lower left corner of the "recording" This logo, which is a powerful function of vim. He can record a macro and record all of your keyboard input, including input in insert mode, various commands used in normal mode, and so on when the recording is started. Specific use: First step: In normal mode (non-insert mode, non-visual mode) Press Q keyboard Step two: Select either A-Z or 0-9 as the name of the buffer, ready to start recording the macro step three: normal operation, All operations will be recorded in the buffer defined in the previous step fourth step: Enter the Q stop macro recording in non-insert mode fifth step: Use the name of the buffer defined in the @ + second step. For example, to make the following text line1line-2line3-1l4 into the text System.out.println (line1); System.out.println (line1); System.out.println (line-2); System.out.println (line3-1); System.out.println (L4); observation can find their laws, adding "System.out.println (", "End Add") at the beginning of each line of text; It becomes the following message. Here's a brief look at how to use recording to do this. First move the cursor on the line1, enter QT, ready to start recording, the buffer name is T, the recording action is: Shift + ^ go back to the beginning of the line, press the I key into the insert mode, enter "System.out.println (", press ESC to return to normal mode, Shift + $ Back to the end of the line, press I to enter insert mode, enter "); Press the ESC key back to normal mode and press Q to stop recording. Then move the cursor to any of the following lines to enter @ + T. Recording can also be used in conjunction with queries, such as the need to put a file containing a specific string of line comments, can be achieved through such a macro. In normal mode, enter/search string + ENTER, Shift + ^, I, #, ESC, SHIFT + $. The way to automate custom macros is to first enter a number and then enter the name of the @ + buffer. For example [email protected], which means to execute 100 times.

How to use VIM recording

Related Article

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: info-contact@alibabacloud.com 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.