Forrest logo
back to the indent tool

indent:tldr:19620

indent: Format C/C++ source according to the style of Kernighan & Ritchie (K&R).
$ indent ${path-to-source_file-c} ${path-to-indented_file-c} -nbad -bap -nbc -br -c33 -cd33 -ncdb -ce -ci4 -cli0 -cs -d0 -di1 -nfc1 -nfcb -i4 -nip -l75 -lp -npcs -nprs -npsl -nsc -nsob
try on your machine

The given command is using the "indent" utility, which is used for formatting code, specifically for C programming language. Let's break down the options and parameters of the command:

  • ${path-to-source_file-c}: This should be replaced with the actual path to the source file in C that you want to indent.

  • ${path-to-indented_file-c}: This should be replaced with the desired path where the indented version of the source file will be saved.

Options:

  • -nbad: Do not force blank lines after open brace.
  • -bap: Break all function prototype parentheses.
  • -nbc: Do not force blank lines before a comma.
  • -br: Break before boolean operator.
  • -c33: Set 33 characters as the limit for continuation lines.
  • -cd33: Set 33 characters as the limit for comment continuation lines.
  • -ncdb: Do not force spaces between /* and */ in a comment-block.
  • -ce: Preserve the current alignment of the closing brace.
  • -ci4: Set 4 spaces as the indentation step for case labels.
  • -cli0: Do not add extra indentation level for certain "extra labels".
  • -cs: Careful space treatment in expressions.
  • -d0: Do not indent preprocessor directives.
  • -di1: Set 1 space as the indentation step for #else, #endif, and #endif.
  • -nfc1: Do not force comments to start in first column.
  • -nfcb: Do not force blank lines after a function block comment.
  • -i4: Set 4 spaces as the indentation step for code.
  • -nip: Do not '(e*x*' to '0(ex*' transformations.
  • -l75: Set the limit for line width to 75 characters.
  • -lp: Align parentheses at continued lines with the line above.
  • -npcs: Do not put former statement in a new line if parentheses are broken.
  • -nprs: Do not align "complex" declarations by their parameters.
  • -npsl: If a comment line starts too close to the statement with which the comment is associated, escape the nl and start the comment on the next line.
  • -nsc: Do not "simplify" complex function prototypes returned by cdecl.
  • -nsob: Do not break long strings.

These options and parameters are used to customize the indentation and formatting style of the code.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the indent tool