Custom Vim's ' Gg=g ' formatting code

Source: Internet
Author: User
Vim has a gg=GFormat code directives.
How do I customize this custom rule?

Reply content:

Vim has a gg=G format code directive.
How do I customize this custom rule?

This question is a bit big, it's not too realistic to say it all, say some basic concepts for reference:

The first thing that you want to know, gg=G is only the = key, the rest is just to help = determine the role
Range only.

=The working mechanism is this:

    1. First it looks for the user-specified external indent tool and, if any, uses the tool to indent the target range. The option
      to specify an external indent tool is EQUALPRG , you should look at the documentation for it, and
      Vimcasts has a video showing an instance in which Drew Neil demonstrates how to use Par to
      Format plain text, followed by an example that shows the formatting of HTML with Pandoc. Although the two examples are
      using formatprg and formatexpr parameters (corresponding to GQ instead of = , formatting
      Rather than indentation), but the principle and usage are interlinked.
    2. However, the EQUALPRG default value is empty, and if you do not have the appropriate external indent tool, Vim uses the built-in
      Indent function c-indenting and ' Lisp ' , You'd better take a look at both of these documents. In addition, if you use the
      Vim compile without the built-in indentation function, you will use the self-contained indent () function to work--
      This is the last resort, the document is also worth a look (you can use to write your own indentation script). Another important setting for
    3. is indentexpr . Just said that if EQUALPRG is not set, = uses the
      c-indenting and Lisp features, but if you set the Indentexpr , the
      generation of the preceding and all other built-in indent expressions (indent-expression) are taken.

If you equalprg indentexpr are not clear about and silly, it is simple: the former only affects = the effect of
The latter determines all indentation functions, such as in addition to the use of the = adjustment indentation, in the INPUT mode
The line feed Vim also automatically adjusts the indentation. So indentexpr the scope of the impact is even greater, and it is used to define
The main way to indent rules (and one that is also indentkeys useful, both of which are more well-documented).

  • 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.