How to use the Linux indent command

Source: Internet
Author: User
Tags case statement comments function definition logical operators nfca

The Linux indent command is used to adjust the format of the original C code file.

Indent can identify and format C's original code file to facilitate reading by programmers.

Syntax:

Indent [parameter] [source file] or indent [parameter] [source file] [-o target file]

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

Description of Indent code formatting:

Indent parameter used Value Description
-- Blank-lines-after-declarations Bad Add blank lines after variable declaration
-- Blank-lines-after-procedures Bap Add blank lines after function completion
-- Blank-lines-before-block-comments Bbb Add blank lines before block comments
-- Break-before-boolean-operator Bbo Long rows, before logical operators
-- Blank-lines-after-commas Nbc In the variable declaration, variables separated by commas are not separated.
-- Braces-after-if-line Bl "If" and "{" are divided into two rows.
-- Brace-indent 0 Bli0 "{" Do not continue indent
-- Braces-after-struct-decl-line Bytes Define structure, "struct" and "{" Branch
-- Comment-indentationn C33 The comment after the statement starts at row 33.
-- Declaration-comment-columnn Cd33 After the variable is declared, the comment starts at row 33.
-- Comment-delimiters-on-blank-lines Ncdb Do not change single-line comments to block comments
-- Cuddle-do-while Ncdw "Do --- while", "while" and "}" in front of it start with another line
-- Cuddle-else Nce "Else" and "}" start with another line
-- Case-indentation 0 Cli0 The case statement in the switch has 0 spaces.
-- Else-endif-columnn Cp33 # Else, # note after endif starts at line 33
-- Space-after-cast Cs Add space after type conversion
-- Line-comments-indentation n D0 Single row comment (not starting from 1 column), not indented to left
-- Break-function-decl-args Nbfda Close: One row of function parameters
-- Declaration-indentationn Di2 Variable Declaration. The variable starts in two rows, that is, it does not have to be aligned.
-- Format-first-column-comments Nfc1 Do not format the comment starting from the first line
-- Format-all-comments Nfca Disable the function of formatting all comments.
-- Honor-newlines Hnl Prefer to break long lines at the position of newlines in the input.
-- Indent-leveln I4 Set the number of characters to indent. If it is an integer multiple of the tabs, use the tab to indent. Otherwise, use spaces to fill the tab.
-- Parameter-indentationn Ip5 In the old style function definition, the parameter description is indented by five spaces.
-- Line-length 75 L75 The maximum number of non-commented rows is 75.
-- Continue-at-parentheses Lp The last line starts with parentheses.
-- Space-after-procedure-Cils Pcs Insert a space between the function and "("
-- Space-after-parentheses Nprs Do not insert spaces before "(" ")"
-- Procnames-start-lines Psl Define the function name and return type in two rows
-- Space-after- Saf For is followed by spaces.
-- Space-after-if Sai If is followed by a space
-- Space-after-while Saw While followed by spaces
-- Start-left-side-of-comments Nsc Not adding * in the generated block comment *
-- Swallow-optional-blank-lines Nsob Do not remove empty rows that can be added
-- Space-special-semicolon Nss The for or while statement of a row is not empty before.
-- Tab-size Ts4 A tab contains four spaces (to divide "-in ")
-- Use-tabs Ut Use tab to indent

The above is a detailed introduction to the use of Linux indent commands. I hope you will gain some benefits after reading them.

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.