Using Macros macro in VIM

Source: Internet
Author: User

Macros are a collection of commands and are widely used, including the word editor in MS Office, the Excel editor and various text editors, and Vim, one of the most powerful text editors in Linux systems, also supports macro operations, and this section briefly describes the use of macros in Vim, First look at the following macro commands

    • q* Start Recording macros
    • Q Stop Recording macro
    • @* executing a macro
    • @@ 重复 executes the last @* command once

The above commands are used under the general mode of Vim (normal), where * represents a number and a word character, and the regular expression rule is: [0-9a-za-z]

    • : Help Recording viewing macros

For example, in the general mode of entering QQ will see the status bar below vim appears recording, this means that you have started recording macro to register Q, you can also use Q as the ID of the macro, the command will be recorded in the macro, again in general mode, press Q to stop the macro recording, You can call the macro via @q later.

To give a simple example, here's a snippet of code:

function(name,value,count){    ...}function(dc,mel){    ...}function(op,ts,n){    ...}

Now you want to modify the declaration format of the function so that a space is added between multiple arguments
1. First QQ to start a macro recording, command mode input: s/,/,\/g
2. Q to end macro recording
3. Move to the next function declaration position @q Execute Macro command

Using Macros macro in VIM

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.