Skip to content
Abrar Syed edited this page Jun 3, 2013 · 5 revisions
                     http://stephenc.github.com/jastyle

                   jAstyle is based on Artistic Style 1.23

Usage : java -jar jastyle.jar [options] Source1.java Source2.java [...]

      java -jar jastyle.jar [options] < Original > Beautified

When indenting a specific file, the resulting indented file RETAINS the

original file-name. The original pre-indented file is renamed, with a

suffix of ".orig" added to the original filename.

Wildcards (* and ?) may be used in the filename.

A 'recursive' option can process directories recursively.

By default, astyle is set up to indent C/C++/C#/Java files, with 4 spaces

per indent, a maximal indentation of 40 spaces inside continuous statements, and NO formatting.

Option's Format:

Long options (starting with '--') must be written one at a time.

Short options (starting with '-') may be appended together.
Thus, -bps4 is the same as -b -p -s4.

Predefined Style Options:

--style=allman  OR  --style=bsd  OR  -A1
Allman style formatting/indenting.
Broken brackets (this is the default).

--style=java  OR  -A2
Java style formatting/indenting.
Attached brackets.

--style=k&r  OR  --style=k/r  OR  -A3
Kernighan & Ritchie style formatting/indenting.
Linux brackets.

--style=stroustrup  OR  -A4
Stroustrup style formatting/indenting.
Stroustrup brackets.

--style=whitesmith  OR  -A5
Whitesmith style formatting/indenting.
Broken, indented brackets.
Indented class blocks and switch blocks.

--style=banner  OR  -A6
Banner style formatting/indenting.
Attached, indented brackets.
Indented class blocks and switch blocks.

--style=gnu  OR  -A7
GNU style formatting/indenting.

Broken brackets, indented blocks, indent is 2 spaces.

--style=linux  OR  -A8
GNU style formatting/indenting.
Linux brackets, indent is 8 spaces.

Tab and Bracket Options:

default indent option
If no indentation option is set,
the default option of 4 spaces will be used.

--indent=spaces=#  OR  -s#
Indent using # spaces per indent. Not specifying #
will result in a default of 4 spaces per indent.

--indent=tab  OR  --indent=tab=#  OR  -t  OR  -t#
Indent using tab characters, assuming that each
tab is # spaces long. Not specifying # will result
in a default assumption of 4 spaces per tab.

--indent=force-tab=#  OR  -T#
Indent using tab characters, assuming that each
tab is # spaces long. Force tabs to be used in areas
Astyle would prefer to use spaces.

default brackets option
If no brackets option is set,
the brackets will be changed.

--brackets=break  OR  -b
Break brackets from pre-block code (i.e. ANSI C/C++ style).

--brackets=attach  OR  -a
Attach brackets to pre-block code (i.e. Java/K&R style).

--brackets=linux  OR  -l
Break definition-block brackets and attach command-block
brackets.

--brackets=stroustrup  OR  -u
Attach all brackets except function definition brackets.

Indentation options:

--indent-classes  OR  -C
Indent 'class' blocks, so that the inner 'public:',
'protected:' and 'private: headers are indented in
relation to the class block.

--indent-switches  OR  -S
Indent 'switch' blocks, so that the inner 'case XXX:'
headers are indented in relation to the switch block.

--indent-cases  OR  -K
Indent case blocks from the 'case XXX:' headers.
Case statements not enclosed in blocks are NOT indented.

--indent-blocks  OR  -G
Add extra indentation entire blocks (including brackets).

--indent-brackets  OR  -B
Add extra indentation to '{' and '}' block brackets.
--indent-namespaces  OR  -N
Indent the contents of namespace blocks.

--indent-labels  OR  -L
Indent labels so that they appear one indent less than
the current indentation level, rather than being
flushed completely to the left (which is the default).

--indent-preprocessor  OR  -w
Indent multi-line #define statements.

--max-instatement-indent=#  OR  -M#

Indent a maximal # spaces in a continuous statement,
relative to the previous line.

--min-conditional-indent=#  OR  -m#

Indent a minimal # spaces in a continuous conditional
belonging to a conditional header.

Formatting options:

--break-blocks  OR  -f
Insert empty lines around unrelated blocks, labels, classes, ...

--break-blocks=all  OR  -F
Like --break-blocks, except also insert empty lines
around closing headers (e.g. 'else', 'catch', ...).

--break-closing-brackets  OR  -y
Break brackets before closing headers (e.g. 'else', 'catch', ...).
Use with --brackets=attach, --brackets=linux,
or --brackets=stroustrup.

--break-elseifs  OR  -e
Break 'else if()' statements into two different lines.

--delete-empty-lines  OR  -x

Delete empty lines within a function or method.
It will NOT delete lines added by the break-blocks options.

--pad-oper  OR  -p
Insert space paddings around operators.

--pad-paren  OR  -P
Insert space padding around parenthesis on both the outside
and the inside.

--pad-paren-out  OR  -d
Insert space padding around parenthesis on the outside only.

--pad-paren-in  OR  -D
Insert space padding around parenthesis on the inside only.

--unpad-paren  OR  -U
Remove unnecessary space padding around parenthesis.  This
can be used in combination with the 'pad' options above.

--keep-one-line-statements  OR  -o
Don't break lines containing multiple statements into
multiple single-statement lines.

--keep-one-line-blocks  OR  -O
Don't break blocks residing completely on one line.

--convert-tabs  OR  -c
Convert tabs to the appropriate number of spaces.

--fill-empty-lines  OR  -E
Fill empty lines with the white space of their
previous lines.

--mode=c
Indent a C or C++ source file (this is the default).

--mode=java
Indent a Java source file.

--mode=cs
Indent a C# source file.

Other options:

--recursive  OR  -r  OR  -R
Process subdirectories recursively.

--options=####
Specify an options file #### to read and use.

--options=none
Disable the default options file.

--version  OR  -V
Print version number.

--help  OR  -h  OR  -?
Print this help message.

--suffix=####
Append the suffix #### instead of '.orig' to original filename.

--suffix=none  OR  -n
Do not retain a backup of the original file.
Only the command-line parameters will be used.

Unsupported options:

--exclude=####
Specify a file or directory #### to be excluded from processing.

--errors-to-stdout  OR  -X
Print errors and help information to standard-output rather than
to standard-error.

--preserve-date  OR  -Z
The date and time modified will not be changed in the formatted file.

--verbose  OR  -v
Verbose mode. Extra informational messages will be displayed.

--formatted  OR  -Q
Formatted display mode. Display only the files that have been formatted.

--quiet  OR  -q
Quiet mode. Suppress all output except error messages.

Default options file:

Artistic Style looks for a default options file in the
following order:

1. The contents of the ARTISTIC_STYLE_OPTIONS environment
   variable if it exists.

If a default options file is found, the options in this file will be parsed BEFORE the command-line options.

Long options within the default option file may be written without
the preliminary '--'.