[Practical.vim (2012.9)]. DREW.NEIL.TIP97 Study Summary

Source: Internet
Author: User

Meet the Global Command

The :global command allows us-to-run an Ex-command on the matches a particular pattern. Let's start by studying its syntax. The:global command takes the following form (See:h: g):
: The global command allows us to execute the ex command on each line of text that matches a particular pattern. We first learn the grammar of it. : The Global command form is as follows

global/{pattern}/ [cmd]

The

The default range for The:global command is the entire file (%). That's sets it apart from the very other EX commands, including:d elete,: Substitute, And:normal, whose range are the current Li NE (.) By default.
: The default range for the global command is (%) that is, the full-text range, and the other ex commands, such as the default range for Delete,:substitude,:normal: The default range for these commands is (.) The current row. The
the {pattern} field integrates with search history. That means we can leave it blank and Vim would automatically use the current search pattern.
{pattern} can be integrated with search history. means that we can leave this item blank, and Vim will automatically use the current search pattern.
The [cmd] could is any ex command except for another:global command
[cmd] can be anything other than: the global command.

We can invert the behavior of the:global command either by running:global! Or:vglobal (Mnemonic:invert). Each of the these tells Vim-to-execute [cmd] on the doesn ' t match the specified pattern.
We can reverse: the effect of global is by using :global! or :vglobal . These symbols tell vim to execute commands on each line that does not match the pattern[cmd]

The:global command works by making-passes through the lines specified by [range]. In the first pass, Vim marks the matches the specified {pattern}. Then on the second pass, the [CMD] are executed for each marked line. The [CMD] can accept a range of its own, which allows us to operate on multiline regions.
: When the global command executes, the row specified by [range] is passed two times. At the first pass, VIM labels the rows that match {pattern} , and then, on the second pass, the marked rows execute the [cmd] command. The [cmd] command can accept the range itself, allowing us to execute commands on multiple lines.

[Practical.vim (2012.9)]. DREW.NEIL.TIP97 Study Summary

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.