Running a Vim macro on a set of lines with Norm

Source: Internet
Author: User

We provide a full-text selection and then run Macros in the selected row. Normal is a very useful thing. Its meaning is to run some operations under the norm model in the command, it provides the possibility of many combined operations and expands the dimensions of using vim, such

: G // \ // norm dd can delete all commentsCodeLine.

It's occasionally handy to be able to run a macro that you 've got ready on aspecific subset of lines of the file, or perhaps just for every line. fortunately, there's a way to do this, too.

Using: NormalCommand, you're able to run macros from the ex command line:

 
: Normal @

All it takes is prefixing this with any sort
Range definition to allowyou to run a macro on any set of lines that you're able to define.

Run the macro on each line of the whole Buffer:

 
: % Normal @

Between lines 10 and 20:

 
: 10, 20 normal @

On the lines in the current visual selection:

 
: '<,'> Normal @

On the lines containing the pattern VIM:

 
: G/Vim/normal @

When you get confident using this,: NormIs a nice abbreviation to use.

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.