Forrest logo
back to the indent tool

indent:tldr:c5467

indent: Format C/C++ source according to the Berkeley style.
$ indent ${path-to-source_file-c} ${path-to-indented_file-c} -nbad -nbap -bc -br -c33 -cd33 -cdb -ce -ci4 -cli0 -di16 -fc1 -fcb -i4 -ip -l75 -lp -npcs -nprs -psl -sc -nsob -ts8
try on your machine

The given command "indent" is used to format C source code files. It takes two arguments: the path to the source file (the file you want to format) and the path to the indented file (the file where the formatted code will be saved).

Here is an explanation of the options used in the command:

  • -nbad: Do not insert blank lines before certain block comments.
  • -nbap: Do not align arguments on subsequent lines in parentheses.
  • -bc: Place the opening brace of a function definition in the same line as the function name.
  • -br: Place the closing brace of a function definition in the same line as the opening brace.
  • -c33: Limit the number of characters per line to 33.
  • -cd33: Break lines longer than limit at a space.
  • -cdb: Indent braces at the same level as the code block they open.
  • -ce: Place the else keyword starting a line.
  • -ci4: Indent using 4 spaces.
  • -cli0: Do not align struct members on subsequent lines.
  • -di16: Indent preprocessor control blocks by 16 spaces.
  • -fc1: Function declarations and definitions with 1 space between the type and the function name.
  • -fcb: Brace style for function declarations and definitions: opening brace on a new line.
  • -i4: Indent using 4 spaces.
  • -ip: Indent preprocessor conditional blocks.
  • -l75: Limit the number of characters per line to 75.
  • -lp: Long function declarations and definitions on separate lines.
  • -npcs: Do not space out C-style comments.
  • -nprs: Remove extra space before closing parenthesis.
  • -psl: Place a space before the opening parenthesis of a function call.
  • -sc: Place a space after a semicolon.
  • -nsob: Do not place a space before an opening brace.
  • -ts8: Use a tab size of 8 characters.

These options provide specific formatting rules and preferences for the indentation and layout of the code. The command will apply these options to the source file and save the formatted code to the indented file.

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