Linux code format conversion-indent

Source: Internet
Author: User

Linux Kernel has a script lindent that helps you format your code in a good code style.
For example:// Usr/src/linux-headers-2.6.22-14/scripts/lindent

Common settings:
Indent-NPRO-Kr-I4-ts4-sob-L80-SS-bl-Bli 0

(I like this style)

Parameter description:
-NPRO or -- ignore-profile do not read indent's configuration file. indent. Pro.
-Kr specifies the format of kernighan & Ritchie. It can be changed to-orig or BSD.
-I4 -- indent-level: set the number of cells to 4.
-Ts4: Set the tab Length
-Sob or -- swallow-optional-blank-lines Delete unnecessary blank lines.
-Line feed of L80 Code exceeding 80
-SS or -- space-special-semicolon if the for section contains only one line, add a space before the semicolon.
-NCs or -- no-space-after-casts should not be empty after cast.
-BL {branch display
-Bli 0 parentheses indent to 0

I usually use:

Indent-NPRO-nip-NLP-npsl-I4-ts4-sob-L200-SS-bl-Bli 0Code File Name


Function Description: adjusts the format of the original C code file.

Syntax: indent [parameter] [source file] or indent [parameter] [source file] [-O target file]

Note: Indent can identify and format the original code file of C to facilitate reading by programmers.

Parameters:
-Bad or -- blank-lines-after-declarations: Add blank lines to the declaration section.
-Bap or -- blank-lines-after-Procedures add blank lines in the program or.
-BBB or -- blank-lines-after-block-Comments add blank lines after the comment section.
-BC or -- blank-lines-after-commas in the Declaration section, if there is a comma, It is a line break.
-BL or -- braces-after-if-line if (or else, for, and so on) are different from "{" in the subsequent execution section, and "}" is a row.
-Set the number of BLI <shrink cells> or -- brace-indent <shrink cells>.
-Br or -- braces-on-if-line if (or else, for, and so on) are different from the "{" of the subsequent execution segment, and "}" is a row.
-BS or -- blank-before-sizeof is empty after sizeof.
-C <Number of columns> or -- Comment-indentation <Number of columns> place comments in the column specified on the right of the program code.
-CD <Number of columns> or -- Declaration-comment-column <Number of columns> place comments in the column specified on the right of the Declaration.
-The CDB or -- Comment-delimiters-on-blank-lines annotator is a line.
-Ce or -- cuddle-else place the else after "}" (the end of the IF execution segment.
-Ci <Number of reduced bins> or -- continuation-indentation <Number of reduced bins> specifies the number of bins after a line break when the length is too long.
-When you use case-based CLI <contract number> or -- Case-indentation-<contract number>, switch compresses the number of cells.
-CP <Number of columns> or-else-endif-column <Number of columns> place comments in the column specified on the right of the else and elseif statements.
-Cs or -- space-after-cast is empty after cast.
-D <Number of shrink cells> or-line-comments-indentation <Number of shrink cells> sets the number of shrink cells for comments not placed on the right of the program code.
-Di <Number of columns> or -- Declaration-indentation <Number of columns> place the variables of the Declaration section in the specified column.
-FC1 or -- format-first-column-Comments: set the format of the comment placed at the top of each line.
-FCA or -- format-all-Comments: set the format of all comments.
-GNU or -- GNU-style. specifies the GNU format, which is the default value.
-I <number of cells> or -- indent-level <number of cells> sets the number of cells to be scaled down.
-IP <number of cells> or -- Parameter-indentation <number of cells> sets the number of cells to be scaled down.
-Kr or -- k-and-R-style. Specify the format of kernighan & Ritchie.
-LP or -- continue-at-Parentheses describes long and line breaks. When the description contains an arc, the content of the Start column of each line in the arc is vertically arranged.
-Nbad or -- no-blank-lines-after-declarations do not add blank lines after the declaration section.
-NBAP or -- no-blank-lines-after-procedures do not add blank lines after the program.
-Nbbb or -- no-blank-lines-after-block-comments do not add blank lines after the comment section.
-For NBC or -- no-blank-lines-after-commas in the Declaration section, do not wrap the line even if a comma appears.
-Ncdb or -- no-comment-delimiters-on-blank-lines annotator should not be a line of its own.
-Nce or -- Dont-cuddle-else do not place the else after.
-NCs or -- no-space-after-casts should not be empty after cast.
-Nfc1 or -- Dont-format-first-column-comments do not format comments placed at the front of each line.
-Nfca or -- Dont-format-comments do not format any comments.
-Do not contract the nip or -- no-parameter-indentation parameter.
-NLP or -- Dont-line-up-parentheses refer to long and line breaks. If the description contains an arc, you do not have to vertically arrange the start column of each line in the ARC.
-NPCs or -- no-space-after-function-call-names do not add spaces after the called function name.
-NPRO or -- ignore-profile do not read indent's configuration file. indent. Pro.
-Put the npsl or -- Dont-break-procedure-type program type in the same line as the program name.
-Do not add an asterisk (*) to the left of the NSC or -- Dont-star-Comments annotation (*).
-Nsob or -- leave-optional-semicolon does not need to process redundant blank rows.
-Nss or -- Dont-space-special-semicolon if the for or while section contains only one row, no space is added before the semicolon.
-NV or -- no-verbosity does not display detailed information.
-Orig or -- original uses the Berkeley format.
-PCs or -- space-after-procedure-CILS Add a space between the called function name and.
-The PSL or -- procnames-start-lines program type is placed in the first line of the program name.
-SC or -- start-left-side-of-Comments add an asterisk (*) to the left of each line comment (*).
-Sob or -- swallow-optional-blank-lines Delete unnecessary blank lines.
-SS or -- space-special-semicolon if there is a row in the for or swile section, add a space before the semicolon.
-St or -- standard-output displays the result on the standard output device.
-T: the data type name is scaled down.
-Set the length of the tab in ts <number of cells> or -- tab-size <number of cells>.
-V or -- verbose displays detailed information during execution.
-Version: displays the version information.

Alias myindent = 'indent-NPRO-Kr-bl-nce-bli0-I2-ts2-sob-L80-nfc1-SS-NCS'

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.