Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux indent Command

Linux indent Command

Linux Command Reference Linux Command Reference

The Linux indent command is used to adjust the formatting of C source code files.

indent recognizes C source code files and formats them for easier reading by programmers.

Syntax

indent [参数][源文件] 或 indent [参数][源文件][-o 目标文件]

Parameters:

Indent code formatting notes

indent options used Value Meaning
--blank-lines-after-declarations bad Add a blank line after variable declarations
--blank-lines-after-procedures bap Add a blank line after functions
--blank-lines-before-block-comments bbb Add a blank line before block comments
--break-before-boolean-operator bbo Break long lines before logical operators
--blank-lines-after-commas nbc Do not break comma-separated variables in declarations
--braces-after-if-line bl Put "if" and "{" on separate lines
--brace-indent 0 bli0 Do not continue indenting "{"
--braces-after-struct-decl-line bls When defining a structure, put "struct" and "{" on separate lines
--comment-indentationn c33 Comments after statements start at column 33
--declaration-comment-columnn cd33 Comments after variable declarations start at column 33
--comment-delimiters-on-blank-lines ncdb Do not convert single-line comments to block comments
--cuddle-do-while ncdw Put the "while" of "do --- while" and the preceding "}" on a new line
--cuddle-else nce Put "else" and the preceding "}" on a new line
--case-indentation 0 cli0 Indent case statements in switch by 0 spaces
--else-endif-columnn cp33 Comments after #else and #endif start at column 33
--space-after-cast cs Add a space after type casts
--line-comments-indentation n d0 Do not outdent single-line comments (those not starting at column 1)
--break-function-decl-args nbfda Disable: one function parameter per line
--declaration-indentationn di2 In variable declarations, variables start on 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 that formats all comments
--honour-newlines hnl Prefer to break long lines at the position of newlines in the input.
--indent-leveln i4 Set the number of characters for indentation. If it is a multiple of tab, use tabs for indentation; otherwise, pad with spaces.
--parameter-indentationn ip5 In old-style function definitions, indent parameter declarations by 5 spaces
--line-length 75 l75 Maximum length of non-comment lines is 75
--continue-at-parentheses lp Continuation lines start from the parentheses that appeared on the previous line
--space-after-procedure-calls pcs Insert a space between a function and "("
--space-after-parentheses nprs Do not insert a space after "(" or before ")"
--procnames-start-lines psl Define the function name and return type on two separate lines
--space-after-for saf Add a space after for
--space-after-if sai Add a space after if
--space-after-while saw Add a 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 a space before ";".
--tab-size ts4 One tab equals 4 spaces (must divide evenly into "-in")
--use-tabs ut Use tabs for indentation

Linux Command Reference Linux Command Reference