← 返回命令列表

Linux command

indent 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Format C source file

indent [source.c]

Format to specific style

indent -kr [source.c]

GNU style formatting

indent -gnu [source.c]

BSD style formatting

indent -orig [source.c]

Output to different file

indent [input.c] -o [output.c]

Set tab width to 4 spaces

indent -ts4 [source.c]

Set indentation to 4 spaces per level

indent -i4 [source.c]

说明

indent reformats C source code according to specified style guidelines. It handles indentation, brace placement, spacing, and line breaking. The tool supports predefined styles (K&R, GNU, BSD) and extensive customization. It can modify files in place or write to new files.

参数

-kr
Kernighan & Ritchie style.
-gnu
GNU coding style.
-orig
Original BSD style.
-linux
Linux kernel style.
-ts _N_
Set tab size.
-i _N_
Set indentation level.
-l _N_
Maximum line length.
-o _FILE_
Output file.
-npro
Do not read .indent.pro profile files.
-bad
Force blank line after declarations.
-bap
Force blank line after procedure bodies.
-nbc
Do not force newlines after commas in declarations.
--help
Display help information.

FAQ

What is the indent command used for?

indent reformats C source code according to specified style guidelines. It handles indentation, brace placement, spacing, and line breaking. The tool supports predefined styles (K&R, GNU, BSD) and extensive customization. It can modify files in place or write to new files.

How do I run a basic indent example?

Run `indent [source.c]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -kr do in indent?

Kernighan & Ritchie style.