YouTip LogoYouTip

Linux Comm Indent

[![Image 1: Linux Command Manual](#) Linux Command Manual](#) The Linux `indent` command is used to adjust the format of C source code files. `indent` can recognize C source code files and format them to make them easier for programmers to read. ### Syntax indent or indent **Options**: * -bad or --blank-lines-after-declarations Add blank lines after declaration blocks. * -bap or --blank-lines-after-procedures Add blank lines after procedures. * -bbb or --blank-lines-after-block-comments Add blank lines after block comment sections. * -bc or --blank-lines-after-commas In declaration blocks, insert a newline when a comma appears. * -bl or --braces-after-if-line The "{" following if (or else, for, etc.) is on a different line, and the "}" is on its own line. * -bli or --brace-indent Set the indentation level for { }. * -br or --braces-on-if-line The "{" following if (or else, for, etc.) is on the same line, and the "}" is on its own line. * -bs or --blank-before-sizeof Insert a space after sizeof. * -c or --comment-indentation Place comments in the specified column to the right of the code. * -cd or --declaration-comment-column Place comments in the specified column to the right of declarations. * -cdb or --comment-delimiters-on-blank-lines Place comment delimiters on their own line. * -ce or --cuddle-else Place the else immediately after the "}" (end of the if block). * -ci or --continuation-indentation When a statement is too long and wraps, specify the indentation for the continuation line. * -cli or --case-indentation- Set the indentation for case labels within a switch statement. * -cp or -else-endif-column Place comments in the specified column to the right of else and elseif statements. * -cs or --space-after-cast Insert a space after a cast. * -d or -line-comments-indentation For comments not placed to the right of code, set their indentation level. * -di or --declaration-indentation Place variables in declaration blocks in the specified column. * -fc1 or --format-first-column-comments Format comments placed in the first column of a line. * -fca or --format-all-comments Format all comments. * -gnu or --gnu-style Specify the use of GNU style (this is the default). * -i or --indent-level Set the indentation level in spaces. * -ip or --parameter-indentation Set the indentation for parameters. * -kr or --k-and-r-style Specify the use of Kernighan & Ritchie style. * -lp or --continue-at-parentheses When a statement is too long and wraps, and contains parentheses, vertically align the start of each line within the parentheses. * -nbad or --no-blank-lines-after-declarations Do not add blank lines after declaration blocks. * -nbap or --no-blank-lines-after-procedures Do not add blank lines after procedures. * -nbbb or --no-blank-lines-after-block-comments Do not add blank lines after block comment sections. * -nbc or --no-blank-lines-after-commas In declaration blocks, do not insert a newline even when a comma appears. * -ncdb or --no-comment-delimiters-on-blank-lines Do not place comment delimiters on their own line. * -nce or --dont-cuddle-else Do not place the else immediately after the "}". * -ncs or --no-space-after-casts Do not insert a space after a cast. * -nfc1 or --dont-format-first-column-comments Do not format comments placed in the first column of a line. * -nfca or --dont-format-comments Do not format any comments. * -nip or --no-parameter-indentation Do not indent parameters. * -nlp or --dont-line-up-parentheses When a statement is too long and wraps, and contains parentheses, do not vertically align the start of each line within the parentheses. * -npcs or --no-space-after-function-call-names Do not insert a space after the function name in a call. * -npro or --ignore-profile Do not read the indent configuration file `.indent.pro`. * -npsl or --dont-break-procedure-type Place the procedure type and procedure name on the same line. * -nsc or --dont-star-comments Do not add an asterisk (*) to the left of comments. * -nsob or --leave-optional-semicolon Do not remove optional blank lines. * -nss or --dont-space-special-semicolon If a for or while block has only one line, do not insert a space before the semicolon. * -nv or --no-verbosity Do not display verbose information. * -orig or --original Use Berkeley style. * -pcs or --space-after-procedure-calls Insert a space between the function name and the "{" in a call. * -psl or --procnames-start-lines Place the procedure type on the line before the procedure name. * -sc or --start-left-side-of-comments Add an asterisk (*) to the left of each line of a comment. * -sob or --swallow-optional-blank-lines Remove optional blank lines. * -ss or --space-special-semicolon If a for or while block has only one line, insert a space before the semicolon. * -st or --standard-output Display the result on standard output. * -T Indentation for data type names. * -ts or --tab-size Set the length of a tab. * -v or --verbose Display detailed information during execution. * -version Display version information. ### Indent Code Formatting Explanation | indent option used | Value | Meaning | | --- | --- | --- | | --blank-lines-after-declarations | bad | Add blank line after variable declaration | | --blank-lines-after-procedures | bap | Add blank line after function end | | --blank-lines-before-block-comments | bbb | Add blank line before block comment | | --break-before-boolean-operator | bbo | For longer lines, break before logical operators | | --blank-lines-after-commas | nbc | In variable declarations, do not break lines for comma-separated variables | | --braces-after-if-line | bl | "if" and "{" are on separate lines | | --brace-indent 0 | bli0 | "{" does not continue indentation | | --braces-after-struct-decl-line | bls | For struct definition, "struct" and "{" are on separate lines | | --comment-indentationn | c33 | Comment after statement starts at column 33 | | --declaration-comment-columnn | cd33 | Comment after variable declaration starts at column 33 | | --comment-delimiters-on-blank-lines | ncdb | Do not turn single-line comments into block comments | | --cuddle-do-while | ncdw | The "while" in "do ... while" and the preceding "}" are on a new line | | --cuddle-else | nce | The "else" and the preceding "}" are on a new line | | --case-indentation 0 | cli0 | Case statements in switch are indented 0 spaces | | --else-endif-columnn | cp33 | Comment after #else, #endif starts at column 33 | | --space-after-cast | cs | Add space after type cast | | --line-comments-indentation n | d0 | Single-line comments (not starting at column 1) are not indented left | | --break-function-decl-args | nbfda | Off: Function arguments are one per line | | --declaration-indentationn | di2 | Variable declaration, variables start at line 2, i.e., no alignment needed | | --format-first-column-comments | nfc1 | Do not format comments starting at the first column | | --format-all-comments | nfca | Do not enable the switch to format all comments | | --honour-newlines | hnl | Prefer to break long lines at the position of newlines in the input. | | --indent-leveln | i4 | Set indentation level in characters. If it's a multiple of tab size, use tab for indentation, otherwise use spaces. | | --parameter-indentationn | ip5 | In old-style function definitions, parameter descriptions are indented 5 spaces | | --line-length 75 | l75 | Non-comment lines are at most 75 characters long | | --continue-at-parentheses | lp | Continuation lines start from the parenthesis on the previous line | | --space-after-procedure-calls | pcs | Insert a space between function and "(" | | --space-after-parentheses | nprs | Do not insert space after "(" and before ")" | | --procnames-start-lines | psl | Define function name and return type on two separate lines | | --space-after-for | saf | Space after for | | --space-after-if | sai | Space after if | | --space-after-while | saw | Space after while | | --start-left-side-of-comments | nsc | Do not add * in generated block comments | | --swallow-optional-blank-lines | nsob | Do not remove optional blank lines | | --space-special-semicolon | nss | For single-line for or while statements, do not add space before ";". | | --tab-size | ts4 | One tab equals 4 spaces (must be divisible by "-i") | | --use-tabs | ut | Use tab for indentation | [![Image 2: Linux Command Manual](#) Linux Command Manual](#)
← Linux Comm CutLinux Comm Gitview β†’