indent
As of version 1.3, the format of the indent
command is:
indent [options] [input-files] indent [options] [single-input-file] [-o output-file]
This format is different from earlier versions and other versions of
indent
.
In the first form, one or more input files are specified. indent
makes a backup copy of each file, and the original file is replaced with
its indented version. See section Backup Files, for an explanation of how
backups are made.
In the second form, only one input file is specified. In this case, or when the standard input is used, you may specify an output file after the `-o' option.
To cause indent
to write to standard output, use the `-st'
option. This is only allowed when there is only one input file, or when
the standard input is used.
If no input files are named, the standard input is read for input. Also, if a filename named `-' is specified, then the standard input is read.
As an example, each of the following commands will input the program `slithy_toves.c' and write its indented text to `slithy_toves.out':
indent slithy_toves.c -o slithy_toves.out indent -st slithy_toves.c > slithy_toves.out cat slithy_toves.c | indent -o slithy_toves.out
Most other options to indent
control how programs are formatted.
As of version 1.2, indent
also recognizes a long name for each
option name. Long options are prefixed by either `--' or
`+'.(1) In most of this document,
the traditional, short names are used for the sake of brevity.
See section Option Summary, for a list of options, including both long and
short names.
Here is another example:
indent -br test/metabolism.c -l85
This will indent the program `test/metabolism.c' using the `-br' and `-l85' options, write the output back to `test/metabolism.c', and write the original contents of `test/metabolism.c' to a backup file in the directory `test'.
Equivalent invocations using long option names for this example would be:
indent --braces-on-if-line --line-length185 test/metabolism.c indent +braces-on-if-line +line-length185 test/metabolism.c
If you find that you often use indent
with the same options, you
may put those options into a file called `.indent.pro'.
indent
will first look for `.indent.pro' in the current
directory and use that if found. Otherwise, indent
will search
your home directory for `.indent.pro' and use that file if it is
found. This behaviour is different from that of other versions of
indent
, which load both files if they both exist.
Command line switches are handled after processing
`.indent.pro'. Options specified later override arguments
specified earlier, with one exception: Explicitly specified options
always override background options (see section Common styles). You can
prevent indent
from reading an `.indent.pro' file by
specifying the `-npro' option.
Go to the first, previous, next, last section, table of contents.