LinuxCommandLibrary

indent

reformats C source code according to specified style guidelines

TLDR

Format C source file

$ indent [source.c]
copy
Format to specific style
$ indent -kr [source.c]
copy
GNU style formatting
$ indent -gnu [source.c]
copy
BSD style formatting
$ indent -orig [source.c]
copy
Output to different file
$ indent [input.c] -o [output.c]
copy
Set tab width
$ indent -ts[4] [source.c]
copy

SYNOPSIS

indent [options] file [output]

DESCRIPTION

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.

PARAMETERS

-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.
--help
Display help information.

CAVEATS

C-specific. May alter semantics with macros. Backup before use.

HISTORY

indent originated in BSD Unix. The GNU version was developed as part of the GNU project with extended options.

SEE ALSO

clang-format(1), astyle(1), cb(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community