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

NNAAMMEE
     iinnddeenntt — indent and format C program source

SSYYNNOOPPSSIISS
     iinnddeenntt [_i_n_p_u_t_-_f_i_l_e [_o_u_t_p_u_t_-_f_i_l_e]] [--bbaacccc | --nnbbaacccc] [--bbaadd | --nnbbaadd]
            [--bbaaddpp | --nnbbaaddpp] [--bbaapp | --nnbbaapp] [--bbbbbb | --nnbbbbbb] [--bbcc | --nnbbcc]
            [--bbll | --bbrr] [--bbss | --nnbbss] [--cc_n] [--ccpp_n] [--ccdd_n] [--ccddbb | --nnccddbb]
            [--ccee | --nnccee] [--ccii_n] [--ccllii_n] [--dd_n] [--ddii_n] [--ddjj | --nnddjj] [--eeii | --nneeii]
            [--eeeeii | --nneeeeii] [--ffbbss | --nnffbbss] [--ffcc11 | --nnffcc11] [--ffccbb | --nnffccbb] [--ii_n]
            [--iipp | --nniipp] [--ll_n] [--llcc_n] [--llddii_n] [--llpp | --nnllpp] [--llppll | --nnllppll]
            [--nnpprroo] [--PP_f_i_l_e] [--ppccss | --nnppccss] [--ppssll | --nnppssll] [--ssaacc | --nnssaacc]
            [--sscc | --nnsscc] [--ssoobb | --nnssoobb] [--sstt] [--ttaa] [--TT_t_y_p_e_n_a_m_e]
            [--ttppgg | --nnttppgg] [--ttss_n] [--UU_f_i_l_e] [--uutt | --nnuutt] [--vv | --nnvv] [----vveerrssiioonn]

DDEESSCCRRIIPPTTIIOONN
     The iinnddeenntt 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.

     NNOOTTEE: 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, iinnddeenntt 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 iinnddeenntt.

     --bbaacccc, --nnbbaacccc   If --bbaacccc 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: --nnbbaacccc.

     --bbaadd, --nnbbaadd     If --bbaadd is specified, a blank line is forced after every
                     block of declarations.  Default: --nnbbaadd.

     --bbaaddpp, --nnbbaaddpp   This is vaguely similar to --bbaadd 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 --nnbbaaddpp..

     --bbaapp, --nnbbaapp     If --bbaapp is specified, a blank line is forced after every
                     procedure body.  Default: --nnbbaapp.

     --bbbbbb, --nnbbbbbb     If --bbbbbb is specified, a blank line is forced before every
                     block comment.  Default: --nnbbbbbb.

     --bbcc, --nnbbcc       If --bbcc is specified, then a newline is forced after each
                     comma in a declaration.  --nnbbcc turns off this option.
                     Default: --nnbbcc.

     --bbll, --bbrr        Specifying --bbll lines up compound statements like this:

                           if (...)
                           {
                             code
                           }

                     Specifying --bbrr (the default) makes them look like this:

                           if (...) {
                             code
                           }

     --bbss, --nnbbss       Whether a blank should always be inserted after sizeof.
                     The default is --nnbbss..

     --cc_n             The column in which comments on code start.  The default
                     is 33.

     --ccpp_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.

     --ccdd_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.

     --ccddbb, --nnccddbb     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 --ccddbb.

     --ccee, --nnccee       Enables (disables) forcing of `else's to cuddle up to the
                     immediately preceding `}'.  The default is --ccee.

     --ccii_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
                     --llpp is in effect or the continuation indent is exactly
                     half of the main indent.  --ccii defaults to the same value
                     as --ii.

     --ccllii_n           Causes case labels to be indented _n tab stops to the
                     right of the containing sswwiittcchh statement.  --ccllii00..55 causes
                     case labels to be indented half a tab stop.  The default
                     is --ccllii00.

     --dd_n             Controls the placement of comments which are not to the
                     right of code.  For example, --dd11 means that such comments
                     are placed one indentation level to the left of code.
                     Specifying the default --dd00 lines up these comments with
                     the code.  See the section on comment indentation below.

     --ddii_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 --ddii1166.

     --ddjj, --nnddjj       --ddjj left justifies declarations.  --nnddjj indents declara‐
                     tions the same as code.  The default is --nnddjj.

     --eeii, --nneeii       Enables (disables) special eellssee--iiff processing.  If it is
                     enabled, an iiff following an eellssee will have the same
                     indentation as the preceding iiff statement.  The default
                     is --eeii.

     --eeeeii, --nneeeeii     Enables (disables) extra indentation on continuation
                     lines of the expression part of iiff and wwhhiillee statements.
                     These continuation lines will be indented one extra
                     level.  The default is --nneeeeii.

     --ffbbss, --nnffbbss     Enables (disables) splitting the function declaration and
                     opening brace across two lines.  The default is --ffbbss.

     --ffcc11, --nnffcc11     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, --nnffcc11 should be used.  The
                     default is --ffcc11.

     --ffccbb, --nnffccbb     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, --nnffccbb should be used.  Block
                     comments are then handled like box comments.  The default
                     is --ffccbb.

     --ii_n             The number of columns for one indentation level.  The
                     default is 8.

     --iipp, --nniipp       Enables (disables) the indentation of parameter declara‐
                     tions from the left margin.  The default is --iipp.

     --ll_n             Maximum length of an output line.  The default is 78.

     --llcc_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 --ll..

     --llddii_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.

     --llpp, --nnllpp       Lines up code surrounded by parentheses in continuation
                     lines.  With --llpp, 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 --nnllpp in effect:

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

                     With --llpp 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));

     --llppll, --nnllppll     With --llppll, code surrounded by parentheses in continuation
                     lines is lined up even if it would extend past the right
                     margin.  With --nnllppll (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 --nnllpp is selected.

     --nnpprroo           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.

     --PP_f_i_l_e          Read profile from _f_i_l_e.

     --ppccss, --nnppccss     If true (--ppccss) all procedure calls will have a space
                     inserted between the name and the `('.  The default is
                     --nnppccss.

     --ppssll, --nnppssll     If true (--ppssll) 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 --ppssll.

     --ssaacc, --nnssaacc     Control whether parenthesized type names in casts are
                     followed by a space or not.  The default is --nnssaacc.

     --sscc, --nnsscc       Enables (disables) the placement of asterisks (`*'s) at
                     the left edge of all comments.  The default is --sscc.

     --ssoobb, --nnssoobb     If --ssoobb is specified, indent will swallow optional blank
                     lines.  You can use this to get rid of blank lines after
                     declarations.  Default: --nnssoobb.

     --sstt             Causes iinnddeenntt to take its input from stdin and put its
                     output to stdout.

     --ttaa             Automatically add all identifiers ending in "_t" to the
                     list of type keywords.

     --TT_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: --TT can be specified more than once.  You need to
                     specify all the typenames that appear in your program
                     that are defined by ttyyppeeddeeff - 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:
                     ttyyppeeddeeff causes a syntactic change in the language and
                     iinnddeenntt cannot find all instances of ttyyppeeddeeff.

     --ttppgg, --nnttppgg     If --ttppgg 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: --nnttppgg.

     --ttss_n            Assumed distance between tab stops.  The default is 8.

     --UU_f_i_l_e          Adds type names from _f_i_l_e to the list of type keywords.

     --uutt, --nnuutt       Enables (disables) the use of tab characters in the out‐
                     put.  The default is --uutt.

     --vv, --nnvv         --vv turns on `verbose' mode; --nnvv turns it off.  When in
                     verbose mode, iinnddeenntt 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 --nnvv.

     ----vveerrssiioonn       Causes iinnddeenntt to print its version number and exit.

     You may set up your own `profile' of defaults to iinnddeenntt 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 iinnddeenntt 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.

   CCoommmmeennttss
     ‘_B_o_x’ _c_o_m_m_e_n_t_s.  The iinnddeenntt 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
     iinnddeenntt utility fits as many words (separated by blanks, tabs, or new‐
     lines) on a line as possible.  Blank lines break paragraphs.

   CCoommmmeenntt iinnddeennttaattiioonn
     If a comment is on a line with code it is started in the `comment col‐
     umn', which is set by the --cc_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 --dd_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.

   PPrreepprroocceessssoorr lliinneess
     In general, iinnddeenntt 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 (##iiffddeeff......##eennddiiff) is
     recognized and iinnddeenntt attempts to correctly compensate for the syntactic
     peculiarities introduced.

   CC ssyynnttaaxx
     The iinnddeenntt 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.

EENNVVIIRROONNMMEENNTT
     The iinnddeenntt utility uses the HOME environment variable.

FFIILLEESS
     ./.indent.pro  profile file
     ~/.indent.pro  profile file

HHIISSTTOORRYY
     The iinnddeenntt command appeared in 4.2BSD.

BBUUGGSS
     The iinnddeenntt 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
