man astyle (Commandes) - indentation and reformatting filters for C, C++, Java

NAME

astyle - indentation and reformatting filters for C, C++, Java

SYNOPSIS

astyle [OPTIONS] < Original > Beautified

astyle [OPTIONS] [FILE1] [FILE2] [...]

DESCRIPTION

Artistic Style (or astyle) is a reindenter and reformatter of C++, C and Java source code.

When indenting source code, we as programmers have a tendency to use both spaces and tab characters to create the wanted indentation. Moreover, some editors by default insert spaces instead of tabs when pressing the tab key, and other editors (Emacs for example) have the ability to "pretty up" lines by automatically setting up the white space before the code on the line, possibly inserting spaces in a code that up to now used only tabs for indentation.

Since the NUMBER of space characters showed on screen for each tab character in the source code changes between editors (until the user sets up the number to his liking...), one of the standard problems facing programmers when moving from one source code editor to another is that code containing both spaces and tabs that was up to now perfectly indented, suddently becomes a mess to look at when changing to another editor. Even if you as a programmer take care to ONLY use spaces or tabs, looking at other peoples source code can still be problematic.

To address this problem astyle was created - a series of filters, written in C++, that automatically reindent and reformat C/C++/Java source files. These can be used from a command line, or it can be incorporated as classes in another C++ program.

USAGE

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.

By default, astyle is set up to indent C/C++ files, with 4 spaces per indent, a maximal indentation of 40 spaces inside continuous statements, and NO formatting.

OPTIONS

This program follows the usual GNU command line syntax, with long options starting with two dashes (`--'). Long options must be written one at a time. Short options (starting with '-') may be appended together.

Thus, -bps4 is the same as -b -p -s4.

A summary of the options supported by astyle is included below.

Predefined Styling options:

--style=ansi ANSI style formatting/indenting.

--style=kr
Kernighan&Ritchie style formatting/indenting.
--style=gnu
GNU style formatting/indenting.
--style=java
Java mode, with standard java style formatting/indenting.
--style=linux
Linux mode (i.e. 8 spaces per indent, break definition-block brackets but attach command-block brackets.

Indentation options:

-c,--mode=c Indent a C or C++ source file (default)

-j,--mode=java
Indent a Java(TM) source file
-s,-s#,--indent=spaces=#
Indent using # spaces per indent. Not specifying # will result in a default of 4 spaces per indent.
-t,-t#,--indent=tab=#
Indent using tab characters, assuming that each tab is # spaces long. Not specifying # will result in a default assumption of 4 spaces per tab.
-T#,--indent-tab=#
Indent using tab characters, assuming that each tab is # spaces long. Force tabs to be used in areas Astyle would prefer to use spaces.
-C,--indent-classes
Indent 'class' blocks, so that the inner 'public:', relation to the class block.
-S,--indent-switches
Indent 'switch' blocks, so that the inner 'case XXX:' headers are indented in relation to the switch block.
-K,--indent-cases
Indent 'case XXX:' lines, so that they are flush with their bodies..
-N,--indent-namespaces
Indent the contents of namespace blocks.
-B,--indent-brackets
Add extra indentation to '{' and '}' block brackets.
-G,--indent-blocks
Add extra indentation entire blocks (including brackets).
-L,--indent-labels
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).
-m#,--min-conditional-indent=#FR
Indent a minimal # spaces in a continuous conditional belonging to a conditional header.
-M#,--max-instatement-indent=#
Indent a maximal # spaces in a continuous statement, relatively to the previous line.
-E,--fill-empty-lines
Fill empty lines with the white space of their previous lines.
--indent-preprocessor
Indent multi-line #define statements

Formatting options:

-b,--brackets=break
Break brackets from pre-block code (i.e. ANSI C/C++ style).
-a,--brackets=attach
Attach brackets to pre-block code (i.e. Java/K&R style).
-l,--brackets=linux
Break definition-block brackets and attach command-block brackets.
--brackets=break-closing-headers
Break brackets before closing headers (e.g. 'else', 'catch', ..). Should be appended to --brackets=attach or --brackets=linux.
-o,--one-line=keep-statements
Don't break lines containing multiple statements into multiple single-statement lines.
-O,--one-line=keep-blocks
Don't break blocks residing completely on one line
-p,--pad=oper
Insert space paddings around operators only.
--pad=paren
Insert space paddings around parenthesies only.
-P,--pad=all
Insert space paddings around operators AND parenthesies.
--convert-tabs
Convert tabs to spaces.
--break-blocks
Insert empty lines around unrelated blocks, labels, classes, ...
--break-blocks=all
Like --break-blocks, except also insert empty lines around closing headers (e.g. 'else', 'catch', ...).
--break-elseifs
Break 'else if()' statements into two different lines.

Other options:

--suffix=####
Append the suffix #### instead of '.orig' to original filename.
-X,--errors-to-standard-output
Print errors and help information to standard-output rather than to standard-error.
-v,--version
Print version number
-h,-?,--help
Show summary of Options

FILES

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.
2.
The file called .astylerc in the directory pointed to by the HOME environment variable ( i.e. $HOME/.astylerc).
3.
The file called .astylerc in the directory pointed to by the HOMEPATH environment variable ( i.e. %HOMEPATH%.astylerc).

If a default options file is found, the options in this file will be parsed BEFORE the command-line options. Options within the default option file may be written without the preliminary '-' or '--'.

VERSION

1.14.1

BUGS

Explain known bugs here.

SEE ALSO

indent(1)

http://astyle.sourceforge.net

http://www.sourceforge.net/projects/astyle

http://packages.debian.org/astyle

AUTHOR

Tal Davidson <davidsont@bigfoot.com>

This man-page was written by Jan Schaumann <jschauma@netmeister.org> as part of "The Missing Man Pages Project". Please see http://www.netmeister.org/misc/m2p2/index.html for details.

Minor modifications by Luca Filipozzi <lfilipoz@debian.org>.