VI Delete even rows/odd lines

Source: Internet
Author: User
The method for deleting even rows is as follows:
: G/^/+1 D

The above is used: The Gbobal command, the gbobal command format is as follows:

: [Range]global/{pattern}/{command}

The global command is actually performed in two steps: First scan all rows in the specified range of [range], mark the line that matches {pattern}, and then execute the {command} command with the marked row, if the marked row is deleted in a command operation that matches a row before, Move or merge, its markup automatically disappears, and the {command} command is not executed on that line. The {command} can be an ex command, or multiple ex commands separated by |, so that we can perform a number of different operations on rows that are marked or that are addressed from the tag line.

The above command deletes even rows, matches all rows first, and then deletes each other (where +1 is positioned on the next line of the current row). Why is it interlaced? Because the second row is deleted when you execute the +1 d command on the first row, and the second row is marked but no longer exists, the command to delete the third row is not executed.

The command to delete several rows is as follows:

: g/^/d|m

The function of M is to remove the mark of even lines and prevent even rows from being deleted.

You can also delete several rows of even rows, or use the normal command, respectively (the first command is a few lines):

:%norm jkdd
:%norm JDD

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.