Code formatting tool-indent Tool

Source: Internet
Author: User

Today, I found a good tool, which is the indent tool. It can be a "messy" tool written by VI.Code.

Run the command: rpm-Qa | grep indent to check whether the indent tool is installed.

IndentThe tool can format the code into a certain style.

Use commands

 
Indent-Kr-i8 main. c

-KROption indicates K & R style,-I8It indicates the length of 8 spaces. If no-NutOption, a tab is automatically used for every eight indentions. Note:IndentThe command directly modifies the original file instead of printing it on the screen or outputting it to another file, which is different from many UNIX commands. As you can see,-KR
-I8
The Code formatted by the two options already conforms to the Code style described in this chapter. After necessary indentation and blank spaces are added, long lines of code are automatically folded. In the US, we do not add proper blank lines becauseIndentThe tool does not know which lines of code are logically a group. Empty lines must be added by yourself. Of course, the original empty lines will not beIndentDeleted.

If you adopt the kernel encoding style described in this chapter-Kr-i8These two parameters are enough.IndentThe tool also supports other encoding styles. For more information, see man page. SometimesIndentTools are indeed very useful. For example, a project decides to change the encoding style (which is rare) in the middle, or several code files added to a project come from another project with different encoding styles, but it must not be becauseIndentThe tool is reckless. At first, the code was written in disorder and finally relied onIndentTo clean up.

Hurry up and try this command ~~~

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.