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.
Use of the vim-recording command