INDENT(1)                 BSD General Commands Manual                INDENT(1)

NNAAMMEE
     iinnddeenntt — indent and format C program source

SSYYNNOOPPSSIISS
     iinnddeenntt [_i_n_p_u_t_-_f_i_l_e [_o_u_t_p_u_t_-_f_i_l_e]] [--bbaacccc | --nnbbaacccc] [--bbaadd | --nnbbaadd]
            [--bbaaddpp | --nnbbaaddpp] [--bbaapp | --nnbbaapp] [--bbbbbb | --nnbbbbbb] [--bbcc | --nnbbcc]
            [--bbll | --bbrr] [--bbss | --nnbbss] [--cc_n] [--ccpp_n] [--ccdd_n] [--ccddbb | --nnccddbb]
            [--ccee | --nnccee] [--ccii_n] [--ccllii_n] [--dd_n] [--ddii_n] [--ddjj | --nnddjj] [--eeii | --nneeii]
            [--eeeeii | --nneeeeii] [--ffbbss | --nnffbbss] [--ffcc11 | --nnffcc11] [--ffccbb | --nnffccbb] [--ii_n]
            [--iipp | --nniipp] [--ll_n] [--llcc_n] [--llddii_n] [--llpp | --nnllpp] [--llppll | --nnllppll]
            [--nnpprroo] [--PP_f_i_l_e] [--ppccss | --nnppccss] [--ppssll | --nnppssll] [--ssaacc | --nnssaacc]
            [--sscc | --nnsscc] [--ssoobb | --nnssoobb] [--sstt] [--ttaa] [--TT_t_y_p_e_n_a_m_e]
            [--ttppgg | --nnttppgg] [--ttss_n] [--UU_f_i_l_e] [--uutt | --nnuutt] [--vv | --nnvv] [----vveerrssiioonn]

DDEESSCCRRIIPPTTIIOONN
     The iinnddeenntt utility is a _C program formatter.  It reformats the _C program
     in the _i_n_p_u_t_-_f_i_l_e according to the switches.  The switches which can be
     specified are described below.  They may appear before or after the file
     names.

     NNOOTTEE: If you only specify an _i_n_p_u_t_-_f_i_l_e, the formatting is done `in-
     place', that is, the formatted file is written back into _i_n_p_u_t_-_f_i_l_e and a
     backup copy of _i_n_p_u_t_-_f_i_l_e is written in the current directory.  If
     _i_n_p_u_t_-_f_i_l_e is named ‘_/_b_l_a_h_/_b_l_a_h_/_f_i_l_e’, the backup file is named
     ‘_f_i_l_e_._B_A_K’.

     If _o_u_t_p_u_t_-_f_i_l_e is specified, iinnddeenntt checks to make sure that it is dif‐
     ferent from _i_n_p_u_t_-_f_i_l_e.

     The options listed below control the formatting style imposed by iinnddeenntt.

     --bbaacccc, --nnbbaacccc   If --bbaacccc is specified, a blank line is forced around
                     every conditional compilation block.  For example, in
                     front of every #ifdef and after every #endif.  Other
                     blank lines surrounding such blocks will be swallowed.
                     Default: --nnbbaacccc.

     --bbaadd, --nnbbaadd     If --bbaadd is specified, a blank line is forced after every
                     block of declarations.  Default: --nnbbaadd.

     --bbaaddpp, --nnbbaaddpp   This is vaguely similar to --bbaadd except that it only
                     applies to the first set of declarations in a procedure
                     (just after the first `{') and it causes a blank line to
                     be generated even if there are no declarations.  The
                     default is --nnbbaaddpp..

     --bbaapp, --nnbbaapp     If --bbaapp is specified, a blank line is forced after every
                     procedure body.  Default: --nnbbaapp.

     --bbbbbb, --nnbbbbbb     If --bbbbbb is specified, a blank line is forced before every
                     block comment.  Default: --nnbbbbbb.

     --bbcc, --nnbbcc       If --bbcc is specified, then a newline is forced after each
                     comma in a declaration.  --nnbbcc turns off this option.
                     Default: --nnbbcc.

     --bbll, --bbrr        Specifying --bbll lines up compound statements like this:

                           if (...)
                           {
                             code
                           }

                     Specifying --bbrr (the default) makes them look like this:

                           if (...) {
                             code
                           }

     --bbss, --nnbbss       Whether a blank should always be inserted after sizeof.
                     The default is --nnbbss..

     --cc_n             The column in which comments on code start.  The default
                     is 33.

     --ccpp_n            The column in which comments on #else and #endif start.
                     The default is 0, which effectively separates the direc‐
                     tives from comments by a single space.

     --ccdd_n            The column in which comments on declarations start.  The
                     default is for these comments to start in the same column
                     as those on code.

     --ccddbb, --nnccddbb     Enables (disables) the placement of comment delimiters on
                     blank lines.  With this option enabled, comments look
                     like this:

                                   /*
                                    * this is a comment
                                    */

                     Rather than like this:

                                   /* this is a comment */

                     This only affects block comments, not comments to the
                     right of code.  The default is --ccddbb.

     --ccee, --nnccee       Enables (disables) forcing of `else's to cuddle up to the
                     immediately preceding `}'.  The default is --ccee.

     --ccii_n            Sets the continuation indent to be _n.  Continuation lines
                     will be indented that far from the beginning of the first
                     line of the statement.  Parenthesized expressions have
                     extra indentation added to indicate the nesting, unless
                     --llpp is in effect or the continuation indent is exactly
                     half of the main indent.  --ccii defaults to the same value
                     as --ii.

     --ccllii_n           Causes case labels to be indented _n tab stops to the
                     right of the containing sswwiittcchh statement.  --ccllii00..55 causes
                     case labels to be indented half a tab stop.  The default
                     is --ccllii00.

     --dd_n             Controls the placement of comments which are not to the
                     right of code.  For example, --dd11 means that such comments
                     are placed one indentation level to the left of code.
                     Specifying the default --dd00 lines up these comments with
                     the code.  See the section on comment indentation below.

     --ddii_n            Specifies the indentation, in character positions, of
                     global variable names and all struct/union member names
                     relative to the beginning of their type declaration.  The
                     default is --ddii1166.

     --ddjj, --nnddjj       --ddjj left justifies declarations.  --nnddjj indents declara‐
                     tions the same as code.  The default is --nnddjj.

     --eeii, --nneeii       Enables (disables) special eellssee--iiff processing.  If it is
                     enabled, an iiff following an eellssee will have the same
                     indentation as the preceding iiff statement.  The default
                     is --eeii.

     --eeeeii, --nneeeeii     Enables (disables) extra indentation on continuation
                     lines of the expression part of iiff and wwhhiillee statements.
                     These continuation lines will be indented one extra
                     level.  The default is --nneeeeii.

     --ffbbss, --nnffbbss     Enables (disables) splitting the function declaration and
                     opening brace across two lines.  The default is --ffbbss.

     --ffcc11, --nnffcc11     Enables (disables) the formatting of comments that start
                     in column 1.  Often, comments whose leading `/' is in
                     column 1 have been carefully hand formatted by the pro‐
                     grammer.  In such cases, --nnffcc11 should be used.  The
                     default is --ffcc11.

     --ffccbb, --nnffccbb     Enables (disables) the formatting of block comments (ones
                     that begin with `/*\n').  Often, block comments have been
                     not so carefully hand formatted by the programmer, but
                     reformatting that would just change the line breaks is
                     not wanted.  In such cases, --nnffccbb should be used.  Block
                     comments are then handled like box comments.  The default
                     is --ffccbb.

     --ii_n             The number of columns for one indentation level.  The
                     default is 8.

     --iipp, --nniipp       Enables (disables) the indentation of parameter declara‐
                     tions from the left margin.  The default is --iipp.

     --ll_n             Maximum length of an output line.  The default is 78.

     --llcc_n            Maximum length of an output line in a block comment.  The
                     default is 0, which means to limit block comment lines in
                     accordance with --ll..

     --llddii_n           Specifies the indentation, in character positions, of
                     local variable names relative to the beginning of their
                     type declaration.  The default is for local variable
                     names to be indented by the same amount as global ones.

     --llpp, --nnllpp       Lines up code surrounded by parentheses in continuation
                     lines.  With --llpp, if a line has a left paren which is not
                     closed on that line, then continuation lines will be
                     lined up to start at the character position just after
                     the left paren.  For example, here is how a piece of con‐
                     tinued code looks with --nnllpp in effect:

                           p1 = first_procedure(second_procedure(p2, p3),
                             third_procedure(p4, p5));

                     With --llpp in effect (the default) the code looks somewhat
                     clearer:

                           p1 = first_procedure(second_procedure(p2, p3),
                                                third_procedure(p4, p5));

                     Inserting two more newlines we get:

                           p1 = first_procedure(second_procedure(p2,
                                                                 p3),
                                                third_procedure(p4,
                                                                p5));

     --llppll, --nnllppll     With --llppll, code surrounded by parentheses in continuation
                     lines is lined up even if it would extend past the right
                     margin.  With --nnllppll (the default), such a line that would
                     extend past the right margin is moved left to keep it
                     within the margin, if that does not require placing it to
                     the left of the prevailing indentation level.  These
                     switches have no effect if --nnllpp is selected.

     --nnpprroo           Causes the profile files, ‘_._/_._i_n_d_e_n_t_._p_r_o’ and
                     ‘_~_/_._i_n_d_e_n_t_._p_r_o’, to be ignored.

     --PP_f_i_l_e          Read profile from _f_i_l_e.

     --ppccss, --nnppccss     If true (--ppccss) all procedure calls will have a space
                     inserted between the name and the `('.  The default is
                     --nnppccss.

     --ppssll, --nnppssll     If true (--ppssll) the names of procedures being defined are
                     placed in column 1 - their types, if any, will be left on
                     the previous lines.  The default is --ppssll.

     --ssaacc, --nnssaacc     Control whether parenthesized type names in casts are
                     followed by a space or not.  The default is --nnssaacc.

     --sscc, --nnsscc       Enables (disables) the placement of asterisks (`*'s) at
                     the left edge of all comments.  The default is --sscc.

     --ssoobb, --nnssoobb     If --ssoobb is specified, indent will swallow optional blank
                     lines.  You can use this to get rid of blank lines after
                     declarations.  Default: --nnssoobb.

     --sstt             Causes iinnddeenntt to take its input from stdin and put its
                     output to stdout.

     --ttaa             Automatically add all identifiers ending in "_t" to the
                     list of type keywords.

     --TT_t_y_p_e_n_a_m_e      Adds _t_y_p_e_n_a_m_e to the list of type keywords.  Names accu‐
                     mulate: --TT can be specified more than once.  You need to
                     specify all the typenames that appear in your program
                     that are defined by ttyyppeeddeeff - nothing will be harmed if
                     you miss a few, but the program will not be formatted as
                     nicely as it should.  This sounds like a painful thing to
                     have to do, but it is really a symptom of a problem in C:
                     ttyyppeeddeeff causes a syntactic change in the language and
                     iinnddeenntt cannot find all instances of ttyyppeeddeeff.

     --ttppgg, --nnttppgg     If --ttppgg is specified, follow Postgres rules about when to
                     use spaces versus tabs for indentation, that is, use a
                     space instead of a tab if the tab would move only one
                     column and no tab will follow it.  Default: --nnttppgg.

     --ttss_n            Assumed distance between tab stops.  The default is 8.

     --UU_f_i_l_e          Adds type names from _f_i_l_e to the list of type keywords.

     --uutt, --nnuutt       Enables (disables) the use of tab characters in the out‐
                     put.  The default is --uutt.

     --vv, --nnvv         --vv turns on `verbose' mode; --nnvv turns it off.  When in
                     verbose mode, iinnddeenntt reports when it splits one line of
                     input into two or more lines of output, and gives some
                     size statistics at completion.  The default is --nnvv.

     ----vveerrssiioonn       Causes iinnddeenntt to print its version number and exit.

     You may set up your own `profile' of defaults to iinnddeenntt by creating a
     file called _._i_n_d_e_n_t_._p_r_o in your login directory and/or the current direc‐
     tory and including whatever switches you like.  A `.indent.pro' in the
     current directory takes precedence over the one in your login directory.
     If iinnddeenntt is run and a profile file exists, then it is read to set up the
     program's defaults.  Switches on the command line, though, always over‐
     ride profile switches.  The switches should be separated by spaces, tabs
     or newlines.

   CCoommmmeennttss
     ‘_B_o_x’ _c_o_m_m_e_n_t_s.  The iinnddeenntt utility assumes that any comment with a dash
     or star immediately after the start of comment (that is, `/*-' or `/**')
     is a comment surrounded by a box of stars.  Each line of such a comment
     is left unchanged, except that its indentation may be adjusted to account
     for the change in indentation of the first line of the comment.

     _S_t_r_a_i_g_h_t _t_e_x_t.  All other comments are treated as straight text.  The
     iinnddeenntt utility fits as many words (separated by blanks, tabs, or new‐
     lines) on a line as possible.  Blank lines break paragraphs.

   CCoommmmeenntt iinnddeennttaattiioonn
     If a comment is on a line with code it is started in the `comment col‐
     umn', which is set by the --cc_n command line parameter.  Otherwise, the
     comment is started at _n indentation levels less than where code is cur‐
     rently being placed, where _n is specified by the --dd_n command line parame‐
     ter.  If the code on a line extends past the comment column, the comment
     starts further to the right, and the right margin may be automatically
     extended in extreme cases.

   PPrreepprroocceessssoorr lliinneess
     In general, iinnddeenntt leaves preprocessor lines alone.  The only reformat‐
     ting that it will do is to straighten up trailing comments.  It leaves
     embedded comments alone.  Conditional compilation (##iiffddeeff......##eennddiiff) is
     recognized and iinnddeenntt attempts to correctly compensate for the syntactic
     peculiarities introduced.

   CC ssyynnttaaxx
     The iinnddeenntt utility understands a substantial amount about the syntax of
     C, but it has a `forgiving' parser.  It attempts to cope with the usual
     sorts of incomplete and malformed syntax.  In particular, the use of
     macros like:

           #define forever for(;;)

     is handled properly.

EENNVVIIRROONNMMEENNTT
     The iinnddeenntt utility uses the HOME environment variable.

FFIILLEESS
     ./.indent.pro  profile file
     ~/.indent.pro  profile file

HHIISSTTOORRYY
     The iinnddeenntt command appeared in 4.2BSD.

BBUUGGSS
     The iinnddeenntt utility has even more switches than ls(1).

     A common mistake is to try to indent all the _C programs in a directory by
     typing:

           indent *.c

     This is probably a bug, not a feature.

BSD                            December 2, 2016                            BSD
