TrumanWong

indent

Format source files in C language

Supplementary instructions

indent command can identify C original code files and format them to facilitate programmers' reading, modification and other operations.

grammar

indent(option)(source file)
or
indent(option)(source file)(-o target file)

Options

-bad: Add a blank line in the declaration area;
-bap: add blank lines;
-bbb: Add a blank line after the comment;
-bc: In the declaration section, if a comma appears, break the line;
-bl: if (or else, for, etc.) is on a different line from the "{" in the following execution section, and "}" forms its own line -bli <number of indented cells> sets the number of cells for {} indentation;
-br: if (or else, for, etc.) goes with the "{" in the subsequent execution section, and "}" forms its own line;
-bs: leave a space after sizeof;
-c <number of columns>: Place the comment in the specified column on the right side of the program;
-cd <number of columns>: Place the comment in the specified column on the right side of the statement;
-cdb: Comment symbols are on their own line;
-ce: Place else after "}" (the end of the if execution section);
-ci: <Number of indented cells>: When the description is too long and the line breaks, specify the number of indented cells after the line break;
-cli <Number of indented cells>: When using case, switch the number of indented cells;
-cp <number of columns>: Place the comment in the specified column to the right of the else and elseif statements;
-cs: leave a space after case;
-d <number of indented cells>: Set the number of indented cells for comments that are not placed on the right side of the program code;
-di<number of columns>: Place the variables of the declaration section in the specified columns;
-fc1: Set the format of the comment placed at the front of each line;
-fca: Set the format of all comments;
-gnu: Use the specified GNU format, this parameter is the default value;
-i<number of cells>: Set the number of cells for indentation;
-ip<number of cells>: Set the number of indented cells for parameters;
-kr: Specify the format of Kernighan&Ritchie;
-lp: When the description is too long and the line breaks, and the description contains parentheses, the contents of the starting fields of each line in the parentheses are arranged vertically;
-nbad: Do not add a blank line after declaring a section;
-nbap: Do not add blank lines after the program;
-nbbb: Do not add blank lines after the comment section;
-nbc: In the declaration section, even if a comma appears, there will be no line breaks;
-ncdb: Comment symbols do not form a line of their own;
-nce: Do not put else after "}";
-ncs: do not leave a space after case;
-nfc1: Do not format comments placed at the front of each line;
-nfca: No need to format any comments;
-nip: Do not indent parameters;
-nlp: When the description is too long and the line breaks, and the description contains parentheses, there is no need to align the starting fields of each line in the parentheses vertically;
-npcs: Do not add spaces after calling the function name;
-npro: Do not read the indent configuration file ".indent.pro";
-npsl: put the program type and program name on the same line;
-nsc: Do not add an asterisk to the left of the comment;
-nsob: No need to process extra blank lines;
-nss: If the for or while section has only one line, do not add a space before the semicolon;
-nv: Do not display detailed information;
-orig: use berkeley format;
-pcs: Add a space between the calling function name and "{";
-psl: The program type is placed on the line before the program name;
-sc: Add an asterisk to the left of each line of comments;
-sob: delete redundant blank lines;
-ss: If the for or swile section has only one line, add a space before the semicolon;
-st: Display the results on the standard output device;
-T: data type name indentation;
-ts<number of cells>: set the length of tab;
-v: Display detailed execution process;
--version: Display version information.

Example

Use the indent command to add a space after all sizeof in the C language source file "test.c" and enter the following command:

indent -bs /home/rootlocal/desktop/test.c

After executing the above command, the user can open the specified source file to check whether a space is added after sizeof. Since this command has many parameters, users can select appropriate parameters according to actual needs.