1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Artistic Style</title>
- <meta http-equiv="Content-Language" content="en-us" />
- <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
- <meta name="description" content="Artistic Style is a source code indenter, source code formatter, and source code beautifier
- for the C, C++, C# and Java programming languages." />
- <meta name="keywords" content="artistic style, astyle, source code indenter, source code formatter, source code beautifier" />
- <link href="styles.css" rel="stylesheet" type="text/css" />
- <!-- the following styles are additions to astyle.html -->
- <style type="text/css">
- code { color:navy; }
- code.title { font-size:larger; font-weight:bold; }
- p.code { margin-left:0.3in; }
- pre { color:navy; font-weight:bold; }
- span.brace { color:red; }
- span.comment { color:#696969; } /*dimgray*/
- span.option { color:#8B4513; } /*saddlebrown*/
- hr { margin-left:-0.4in }
- </style>
- </head>
- <body>
- <!-- CUT HERE FOR INSERTION INTO SOURCEFORGE DOC MANAGER -->
- <h1>
- Artistic Style 2.01</h1>
- <h2>
- A Free, Fast and Small Automatic Formatter<br />
- for C, C++, C#, and Java Source Code</h2>
- <h3 id="Contents">
- Contents</h3>
- <p class="contents1">
- <a class="contents" href="#_General_Information">General Information</a></p>
- <p class="contents1">
- <a class="contents" href="#_Usage">Usage</a></p>
- <p class="contents1">
- <a class="contents" href="#_Options">Options</a></p>
- <p class="contents1">
- <a class="contents" href="#_Options_File">Options File</a></p>
- <p class="contents1">
- <a class="contents" href="#_Predefined_Style_Options">Predefined Style Options</a></p>
- <p class="contents2">
- <a class="contents" href="#_style=allman">style=allman</a> <a class="contents" href="#_style=java">
- style=java</a> <a class="contents" href="#_style=k&r">style=k&r</a> <a class="contents"
- href="#_style=stroustrup">style=stroustrup</a> <a class="contents" href="#_style=whitesmith">style=whitesmith</a>
- <a class="contents" href="#_style=banner">style=banner</a> <a class="contents" href="#_style=gnu">
- style=gnu</a> <a class="contents" href="#_style=linux">style=linux</a>
- <a class="contents" href="#_style=horstmann">style=horstmann</a> <a class="contents" href="#_style=1tbs">
- style=1tbs</a>
- </p>
- <p class="contents1">
- <a class="contents" href="#_Tab_and_Bracket_Options">Tab and Bracket Options</a>
- </p>
- <p class="contents2">
- <a class="contents" href="#_default_indent">default indent</a> <a class="contents" href="#_indent=spaces">
- indent=spaces</a> <a class="contents" href="#_indent=tab">indent=tab</a>
- <a class="contents" href="#_indent=force-tab">indent=force‑tab</a> <a class="contents"
- href="#_default_brackets">default brackets</a> <a class="contents" href="#_brackets=break">
- brackets=break</a> <a class="contents" href="#_brackets=attach">brackets=attach</a>
- <a class="contents" href="#_brackets=linux">brackets=linux</a> <a class="contents" href="#_brackets=stroustrup">
- brackets=stroustrup</a> <a class="contents" href="#_brackets=horstmann">brackets=horstmann</a>
- </p>
- <p class="contents1">
- <a class="contents" href="#_Indentation_Options">Indentation Options</a></p>
- <p class="contents2">
- <a class="contents" href="#_indent-classes">indent‑classes</a> <a class="contents" href="#_indent-switches">
- indent‑switches</a> <a class="contents" href="#_indent-cases">indent‑cases</a>
- <a class="contents" href="#_indent-brackets">indent‑brackets</a> <a class="contents" href="#_indent-blocks">
- indent‑blocks</a> <a class="contents" href="#_indent-namespaces">indent‑namespaces</a>
- <a class="contents" href="#_indent-labels">indent‑labels</a> <a class="contents" href="#_indent-preprocessor">
- indent‑preprocessor</a> <a class="contents" href="#_indent-col1-comments">indent‑col1‑comments</a>
- <a class="contents" href="#_max-instatement-indent">max‑instatement‑indent</a> <a
- class="contents" href="#_min-conditional-indent">min‑conditional‑indent</a>
- </p>
- <p class="contents1">
- <a class="contents" href="#_Padding_Options">Padding Options</a></p>
- <p class="contents2">
- <a class="contents" href="#_break-blocks">break‑blocks</a> <a class="contents" href="#_break-blocks=all">
- break‑blocks=all</a> <a class="contents" href="#_pad-oper">pad‑oper</a>
- <a class="contents" href="#_pad-paren">pad‑paren</a> <a class="contents" href="#_pad-paren-out">
- pad‑paren‑out</a> <a class="contents" href="#_pad-paren-in">pad‑paren‑in</a>
- <a class="contents" href="#_pad-header">pad‑header</a> <a class="contents" href="#_unpad-paren">
- unpad‑paren</a> <a class="contents" href="#_delete-empty-lines">delete‑empty‑lines</a>
- <a class="contents" href="#_fill-empty-lines">fill‑empty‑lines</a>
- </p>
- <p class="contents1">
- <a class="contents" href="#_Formatting_Options">Formatting Options</a></p>
- <p class="contents2">
- <a class="contents" href="#_break-closing-brackets">break‑closing‑brackets</a> <a
- class="contents" href="#_break-elseifs">break‑elseifs</a> <a class="contents" href="#_add-brackets">
- add‑brackets</a> <a class="contents" href="#_add-one-line-brackets">add‑one‑line‑brackets</a>
- <a class="contents" href="#_keep-one-line-blocks">keep‑one‑line‑blocks</a>
- <a class="contents" href="#_keep-one-line-statements">keep‑one‑line‑statements</a>
- <a class="contents" href="#_convert-tabs">convert‑tabs</a> <a class="contents" href="#_align-pointer">
- align‑pointer</a> <a class="contents" href="#_mode">mode</a>
- </p>
- <p class="contents1">
- <a class="contents" href="#_Other_Options">Other Options</a></p>
- <p class="contents2">
- <a class="contents" href="#_suffix">suffix</a> <a class="contents" href="#_suffix=none">suffix=none</a>
- <a class="contents" href="#_options">options</a> <a class="contents" href="#_options=none">options=none</a>
- <a class="contents" href="#_recursive">recursive</a> <a class="contents" href="#_exclude">exclude</a>
- <a class="contents" href="#_errors-to-stdout">errors‑to‑stdout</a> <a class="contents"
- href="#_preserve-date">preserve‑date</a> <a class="contents" href="#_verbose">verbose</a>
- <a class="contents" href="#_formatted">formatted</a> <a class="contents" href="#_quiet">quiet</a>
- <a class="contents" href="#_lineend">lineend</a> <a class="contents" href="#_version">version</a>
- <a class="contents" href="#_help">help</a>
- </p>
- <p>
- </p>
- <hr />
- <!-- * * * * * * * * * * * * General Information< * * * * * * * * * * * * -->
- <h3 id="_General_Information">
- General Information</h3>
- <h4>
- Line Endings</h4>
- <p>
- Line endings in the formatted file will be the same as the input file. If there are mixed line endings the most
- frequent occurrence will be used. There is also an option to specify or change the line endings.</p>
- <h4>
- File Type</h4>
- <p>
- Artistic Style will determine the file type from the file extension. The extension ".java" indicates a Java file,
- and ".cs" indicates a C# file. Everything else is a C or C++ file. If you are using a non-standard file extension
- for Java or C#, use one of the <code>--mode=</code> options.</p>
- <h4>
- Wildcards and Recursion</h4>
- <p>
- Artistic Style can process directories recursively. Wildcards (such as "*.cpp" or "*.c??") are processed internally.
- If a shell is used it should pass the wildcards to Artistic Style instead of resolving them first. For Linux use
- double quotes around paths whose filename contains wildcards. For Windows use double quotes around paths whose
- filename contains spaces. The "Other Options" section contains information on recursive processing.</p>
- <h4>
- File Names</h4>
- <p>
- When a file is formatted, the newly indented file retains the original file name. A copy of the original file
- is created with an <code><strong>.orig</strong></code> appended to the original file name. (This can be set to
- a different string by the option <code>--suffix=</code>, or suppressed altogether by the options <code>-n</code>
- or <code>--suffix=none</code>). Thus, after indenting <code><em>SourceFile.cpp</em></code> the indented file will
- be named <code><em>SourceFile.cpp</em></code>, while the original pre-indented file will be renamed to <code><em>SourceFile.cpp.orig</em></code>.</p>
- <h4>
- Other Considerations</h4>
- <p>
- Artistic Style can format standard class library statements such as Open GL, wxWidgets, QT, and MFC.</p>
- <p>
- Embedded assembler language is formatted correctly. This includes extended assembly and Microsoft specific assembler
- lines and blocks.</p>
- <p>
- Artistic Style can format embedded SQL statements. The SQL formatting will be maintained as long as the standard
- hanging indent format is used. If the "exec sql" statement is indented more than the following statements, the
- SQL will be aligned in a single column.</p>
- <p>
- Files encoded as UTF‑16 or UTF‑32 will NOT be formatted. These are left unchanged and a warning message
- is displayed. Some compilers do not support these encodings. Other compilers must have a Byte-Order-Mark (BOM)
- to recognize the encoding. To use Artistic Style the files can be converted to the newer UTF‑8 encoding
- with the program iconv. There are Linux and Windows versions available. A sample command line is "iconv ‑f
- UTF‑16 ‑t UTF‑8 filein.cpp >fileout.cpp. Visual Studio can convert the files from the
- "File > Advanced Save Options" menu. Select encoding "Unicode (UTF‑8 with signature) - Codepage 65001".
- There are other development environments and text editors, such as SciTE, that can convert files to UTF‑8.
- </p>
- <p>
- Embedded statements that are multiple-line and are NOT in a C type format, such as Python, are usually mal-formatted.
- (A C type format has blocks enclosed by brackets and statements terminated by a semi-colon). Macros that define
- functions may cause the following code to be mal-formatted because the macro is missing the brackets and semi-colons
- from the definition. If you have source code with these types of statements, exclude them with the <code>--exclude=</code>
- statement described in the "Other Options" section.</p>
- <h4>
- Quick Start</h4>
- <p>
- If you have never used Artistic Style there are a couple of ways to start. One is to run it with no options at
- all. This will format the file with 4 spaces per indent and will leave the brackets unchanged. Another is to use
- one of the predefined styles described in the "Predefined Style Options" section. Select one with a bracket formatting
- style you like. Once you are familiar with the options you can customize the format to your personal preference.</p>
- <p>
- </p>
- <hr />
- <!-- * * * * * * * * * * * * * * * Usage * * * * * * * * * * * * * * * -->
- <h3 id="_Usage">
- Usage</h3>
- <p>
- Artistic style is a console program that receives information from the command line. The format of the command
- line is:</p>
- <pre>astyle [options] <em>SourceFile1 SourceFile2 SourceFile3</em> [ . . . ]
- </pre>
- <p>
- The block parens [ ] indicate that more than one option or more than one filename can be entered. They are NOT
- actually included in the command. For the options format see the following Options section.</p>
- <div class="code">
- <p>
- Example to format a single file:</p>
- <pre>astyle --style=allman /home/user/project/foo.cpp
- </pre>
- <p>
- Example to format all .cpp and .h files recursively:</p>
- <pre>astyle --style=allman --recursive /home/user/project/*.cpp /home/user/project/*.h
- </pre>
- </div>
- <p>
- Another option will format a single file and change the name:</p>
- <pre>astyle [options] < <em>OriginalSourceFile</em> > <em>BeautifiedSourceFile</em>
- </pre>
- <p>
- The <span style="color: #0000a0"><</span> and <span style="color: #0000a0">></span> characters are used
- to redirect the files into standard input (cin) and out of standard output (cout) - don't forget them! With this
- option only one file at a time can be formatted. Wildcards are not recognized, there are no console messages,
- and a backup is not created.</p>
- <p>
- </p>
- <hr />
- <!-- * * * * * * * * * * * * * * * Options * * * * * * * * * * * * * * * -->
- <h3 id="_Options">
- Options</h3>
- <p>
- Not specifying any option will result in 4 spaces per indent, no change in bracket placement, and no formatting
- changes.</p>
- <p>
- Options may be written in two different ways.</p>
- <h4>
- Long options</h4>
- <p>
- These options start with '<strong>--</strong>', and must be written one at a time.<br />
- (Example: '<code>--brackets=attach --indent=spaces=4</code>')</p>
- <h4>
- Short Options</h4>
- <p>
- These options start with a single '<strong>-</strong>', and may be concatenated together.<br />
- (Example: '<code>-bps4</code>' is the same as writing '<code>-b -p -s4</code>'.)</p>
- <p>
- </p>
- <hr />
- <!-- * * * * * * * * * * * * * * Options File * * * * * * * * * * * * * * -->
- <h3 id="_Options_File">
- Options File</h3>
- <p>
- An OPTIONAL default options file may be used to supplement or replace the command line options. </p>
- <ul>
- <li>The command line options have precedence. If there is a conflict between a command line option and an option in
- the default options file, the command line option will be used.</li>
- <li>Artistic Style looks for this file in the following locations (in order):
- <ol>
- <li>the file indicated by the --options= command line option;</li>
- <li>the file and directory indicated by the environment variable ARTISTIC_STYLE_OPTIONS (if it exists);</li>
- <li>the file named .astylerc in the directory pointed to by the HOME environment variable (e.g. "$HOME/.astylerc"
- on Linux);</li>
- <li>the file named astylerc in the directory pointed to by the USERPROFILE environment variable (e.g. "%USERPROFILE%\astylerc"
- on Windows).</li>
- </ol>
- </li>
- <li>This option file lookup can be disabled by specifying --options=none on the command line.</li>
- <li>Options may be set apart by new-lines, tabs, commas, or spaces.</li>
- <li>Long options in the options file may be written without the preceding '--'.</li>
- <li>Lines within the options file that begin with '#' are considered line-comments.</li>
- </ul>
- <p>
- Example of a default options file:</p>
- <div class="code">
- <pre><span class="comment"># this line is a comment</span>
- --brackets=attach <span class="comment"># this is a line-end comment</span>
- <span class="comment"># long options can be written without the preceding '--'</span>
- indent-switches <span class="comment"># cannot do this on the command line</span>
- <span class="comment"># short options must have the preceding '-'</span>
- -t -p
- <span class="comment"># short options can be concatenated together</span>
- -M65Ucv</pre>
- </div>
- <p>
- </p>
- <hr />
- <!-- * * * * * * * * * * * * Predefined Style Options * * * * * * * * * * * * -->
- <h3 id="_Predefined_Style_Options">
- Predefined Style Options</h3>
- <p>
- Predefined Style options define the style by setting other options. The style options always override any individual
- option settings. You will always get the requested style regardless of other defined options.</p>
- <p>
- The predefined style options always set the options brackets=###, indent‑blocks, and indent‑brackets.
- These options can NOT be changed with the individual option settings.</p>
- <p>
- Some styles use the default setting for spaces per indent and some use a different setting. You may use any of
- the indent= options with any style. The indent options that do not set the spaces per indent (indent=spaces, indent=tab,
- or indent=force‑tab) will use the default spaces per tab setting for the style. The indent options that
- set the spaces per indent (indent=spaces=#, indent=tab=#, or indent=force‑tab=#) will use the specified
- spaces per tab setting instead of the default for the style. For the options that set the spaces per indent see
- the following style descriptions.</p>
- <p>
- All other options are available to customize the style. By default, none of the styles indent namespaces. This
- can be changed with the indent‑namespaces option.</p>
- <p>
- </p>
- <p id="_style=allman">
- <code class="title">--style=allman / --style=ansi / --style=bsd / -A1</code><br />
- Allman style formatting/indenting uses broken brackets.</p>
- <div class="code">
- <pre>int Foo(bool isBar)
- <span class="brace">{</span>
- if (isBar)
- <span class="brace">{</span>
- bar();
- return 1;
- <span class="brace">}</span>
- else
- return 0;
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_style=java">
- <code class="title">--style=java / -A2</code><br />
- Java style formatting/indenting uses attached brackets.</p>
- <div class="code">
- <pre>int Foo(bool isBar) <span class="brace">{</span>
- if (isBar) <span class="brace">{</span>
- bar();
- return 1;
- <span class="brace">}</span> else
- return 0;
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_style=k&r">
- <code class="title">--style=k&r / --style=kr / --style=k/r / -A3</code><br />
- Kernighan & Ritchie style formatting/indenting uses linux brackets. Brackets are broken from namespaces, classes,
- and function definitions. Brackets are attached to statements within a function.</p>
- <p>
- Using the k&r option may cause problems because of the &. This can be resolved by enclosing the k&r
- in quotes (e.g. ‑‑style="k&r") or by using one of the alternates ‑‑style=kr or ‑‑style=k/r.</p>
- <div class="code">
- <pre>int Foo(bool isBar)
- <span class="brace">{</span>
- if (isBar) <span class="brace">{</span>
- bar();
- return 1;
- <span class="brace">}</span> else
- return 0;
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_style=stroustrup">
- <code class="title">--style=stroustrup / -A4</code><br />
- Stroustrup style formatting/indenting uses stroustrup brackets. Brackets are broken from function definitions
- only. Brackets are attached to namespaces, classes, and statements within a function. <strong>Indentation</strong>
- is 5 spaces.
- </p>
- <div class="code">
- <pre>int Foo(bool isBar)
- <span class="brace">{</span>
- if (isBar) <span class="brace">{</span>
- bar();
- return 1;
- <span class="brace">}</span> else
- return 0;
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_style=whitesmith">
- <code class="title">--style=whitesmith / -A5</code><br />
- Whitesmith style formatting/indenting uses broken, indented brackets. Class blocks and switch blocks are indented
- to prevent a 'hanging indent' with switch statements and C++ class modifiers (public, private, protected). </p>
- <div class="code">
- <pre>int Foo(bool isBar)
- <span class="brace">{</span>
- if (isBar)
- <span class="brace">{</span>
- bar();
- return 1;
- <span class="brace">}</span>
- else
- return 0;
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_style=banner">
- <code class="title">--style=banner / -A6</code><br />
- Banner style formatting/indenting uses attached, indented brackets. Class blocks and switch blocks are indented
- to prevent a 'hanging indent' with switch statements and C++ class modifiers (public, private, protected). </p>
- <div class="code">
- <pre>int Foo(bool isBar) <span class="brace">{</span>
- if (isBar) <span class="brace">{</span>
- bar();
- return 1;
- <span class="brace">}</span>
- else
- return 0;
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_style=gnu">
- <code class="title">--style=gnu / -A7</code><br />
- GNU style formatting/indenting uses broken brackets and indented blocks. <strong>Indentation</strong> is 2 spaces.
- </p>
- <p>
- Extra indentation is added to blocks <strong>within a function</strong>. The opening bracket for namespaces, classes,
- and functions is not indented.
- </p>
- <div class="code">
- <pre>int Foo(bool isBar)
- <span class="brace">{</span>
- if (isBar)
- <span class="brace">{</span>
- bar();
- return 1;
- <span class="brace">}</span>
- else
- return 0;
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_style=linux">
- <code class="title">--style=linux / -A8</code><br />
- Linux style formatting/indenting uses linux style brackets. Brackets are broken from namespace, class, and function
- definitions. Brackets are attached to statements within a function. <strong>Indentation</strong> is 8 spaces.
- <strong>Minimum conditional indent</strong> is 4 spaces, or one-half the spaces per indent if a different setting
- is used. If you want to change the spaces per indent for this style it will be easier to use the K&R style
- instead.</p>
- <p>
- Also known as Kernel Normal Form (KNF) style, this is the style used in the Linux kernel.</p>
- <div class="code">
- <pre>int Foo(bool isBar)
- <span class="brace">{</span>
- if (isFoo) <span class="brace">{</span>
- bar();
- return 1;
- <span class="brace">}</span> else
- return 0;
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_style=horstmann">
- <code class="title">--style=horstmann / -A9</code><br />
- Horstmann style formatting/indenting uses horstmann style brackets. Brackets are broken with run-in statements.
- Switches are indented. <strong>Indentation</strong> is 3 spaces.
- </p>
- <div class="code">
- <pre>int Foo(bool isBar)
- <span class="brace">{</span> if (isBar)
- <span class="brace">{</span> bar();
- return 1;
- <span class="brace">} </span>else
- return 0;
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_style=1tbs">
- <code class="title">--style=1tbs / --style=otbs / -A10</code><br />
- "One True Brace Style" formatting/indenting uses linux style brackets and adds brackets to unbracketed one line
- conditional statements. In the following example brackets have been added to the "<code>return 0;</code>" statement.
- The option ‑‑add‑one‑line‑brackets can also be used with this style.</p>
- <div class="code">
- <pre>int Foo(bool isBar)
- <span class="brace">{</span>
- if (isFoo) <span class="brace">{</span>
- bar();
- return 1;
- <span class="brace">}</span> else <span class="brace">{</span>
- return 0;
- <span class="brace">}</span>
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <hr />
- <!-- * * * * * * * * * * * * Tab and Bracket Options * * * * * * * * * * * * -->
- <h3 id="_Tab_and_Bracket_Options">
- Tab and Bracket Options</h3>
- <p id="_default_indent">
- <code class="title">default indent option</code><br />
- If no indentation option is set, the default option of 4 spaces will be used (e.g. <code>-s<span class="option">4</span>
- --indent=spaces=<span class="option">4</span></code>).</p>
- <p id="_indent=spaces">
- <code class="title">--indent=spaces / --indent=spaces=<span class="option">#</span> / -s<span class="option">#</span></code><br />
- Indent using # spaces per indent (e.g. <code>-s<span class="option">6</span></code> <code>--indent=spaces=<span
- class="option">6</span></code>). # must be between 2 and 20. Not specifying # will result in a default of
- 4 spaces per indent.</p>
- <p id="_indent=tab">
- <code class="title">--indent=tab / --indent=tab=<span class="option">#</span> / -t / -t<span class="option">#</span></code><br />
- Indent using tab characters. Treat each tab as # spaces (e.g. <code>-t<span class="option">6</span></code> / <code>
- --indent=tab=<span class="option">6</span></code>). # must be between 2 and 20. If no # is set, treats tabs
- as 4 spaces.</p>
- <p id="_indent=force-tab">
- <code class="title">--indent=force-tab / --indent=force-tab=<span class="option">#</span> / -T / -T<span class="option">#</span></code><br />
- Indent using tab characters. Treat each tab as # spaces (e.g. <code>-T<span class="option">6</span></code> / <code>
- --indent=<span lang="en-us">force-</span>tab=<span class="option">6</span></code>). Uses tabs as indents where
- <code>‑‑indent=tab</code> prefers to use spaces, such as inside multi-line statements. # must be between
- 2 and 20. If no # is set, treats tabs as 4 spaces.</p>
- <p id="_default_brackets">
- <code class="title">default brackets option</code><br />
- If no brackets option is set, the brackets will not be changed.</p>
- <p id="_brackets=break">
- <code class="title">--brackets=break / -b</code><br />
- Break brackets from their pre-block statements ( e.g. Allman / ANSI style ).</p>
- <div class="code">
- <pre>void Foo(bool isFoo)
- <span class="brace">{</span>
- if (isFoo)
- <span class="brace">{</span>
- bar();
- <span class="brace">}</span>
- else
- <span class="brace">{</span>
- anotherBar();
- <span class="brace">}</span>
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_brackets=attach">
- <code class="title">--brackets=attach / -a</code><br />
- Attach brackets to their pre-block statements ( e.g. Java style ).</p>
- <div class="code">
- <pre>void Foo(bool isFoo) <span class="brace">{</span>
- if (isFoo) <span class="brace">{</span>
- bar();
- <span class="brace">}</span> else <span class="brace">{</span>
- anotherBar();
- <span class="brace">}</span>
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_brackets=linux">
- <code class="title">--brackets=linux / -l</code><br />
- Break brackets from namespace, class, and function definitions, but attach brackets to statements within a function
- ( e.g. K&R / Linux style ).</p>
- <p>
- With C++ files brackets are attached for function definitions within a class (inline class functions). The brackets
- are also attached for arrays, structs, enums, and other top level objects that are not classes or functions. This
- option is effective for C/C++ files only.</p>
- <div class="code">
- <pre>void Foo(bool isFoo)
- <span class="brace">{</span>
- if (isFoo) <span class="brace">{</span>
- bar();
- <span class="brace">}</span> else <span class="brace">{</span>
- anotherBar;
- <span class="brace">}</span>
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_brackets=stroustrup">
- <code class="title">--brackets=stroustrup / -u</code><br />
- Break brackets from function definitions only. Attach brackets to namespaces, classes, and statements within a
- function ( e.g. Stroustrup style ).</p>
- <p>
- With C++ files brackets are attached for function definitions within a class (inline class functions). The brackets
- are also attached for arrays, structs, enums, and other top level objects that are not classes or functions. This
- option is effective for C/C++ files only.</p>
- <div class="code">
- <pre>void Foo(bool isFoo)
- <span class="brace">{</span>
- if (isFoo) <span class="brace">{</span>
- bar();
- <span class="brace">}</span> else <span class="brace">{</span>
- anotherBar;
- <span class="brace">}</span>
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_brackets=horstmann">
- <code class="title">--brackets=horstmann / -g</code><br />
- Break brackets from their pre-block statements but allow run-in statements on the same line as an opening bracket
- ( e.g. Horstmann style ).</p>
- <div class="code">
- <pre>void Foo(bool isFoo)
- <span class="brace">{</span> if (isFoo())
- <span class="brace">{</span> bar1();
- bar2();
- <span class="brace">}</span>
- else
- <span class="brace">{</span> anotherBar();
- <span class="brace">}</span>
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <hr />
- <!-- * * * * * * * * * * * * * Indentation Options * * * * * * * * * * * * * -->
- <h3 id="_Indentation_Options">
- Indentation Options</h3>
- <p id="_indent-classes">
- <code class="title">--indent-classes / -C</code><br />
- Indent '<code>class</code>' and '<code>struct</code>' blocks so that the blocks '<code>public:</code>', '<code>protected:</code>'
- and '<code>private:</code>' are indented. The struct blocks are indented only if an access modifier is declared
- somewhere in the struct. The entire block is indented. This option is effective for C++ files only.</p>
- <div class="code">
- <pre>class Foo
- <span class="brace">{</span>
- public:
- Foo();
- virtual ~Foo();
- <span class="brace">}</span>;
- </pre>
- <p class="code">
- becomes:</p>
- <pre>class Foo
- <span class="brace">{</span>
- public:
- Foo();
- virtual ~Foo();
- <span class="brace">}</span>;
- </pre>
- </div>
- <p>
- </p>
- <p id="_indent-switches">
- <code class="title">--indent-switches / -S</code><br />
- Indent '<code>switch</code>' blocks so that the '<code>case X:</code>' statements are indented in the <code>switch</code>
- block. The entire case block is indented.</p>
- <div class="code">
- <pre>switch (foo)
- <span class="brace">{</span>
- case 1:
- a += 1;
- break;
- case 2:
- <span class="brace">{</span>
- a += 2;
- break;
- <span class="brace">}</span>
- <span class="brace">}</span>
- </pre>
- <p class="code">
- becomes:</p>
- <pre>switch (foo)
- <span class="brace">{</span>
- case 1:
- a += 1;
- break;
- case 2:
- <span class="brace">{</span>
- a += 2;
- break;
- <span class="brace">}</span>
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_indent-cases">
- <code class="title">--indent-cases / -K</code><br />
- Indent '<code>case X:</code>' blocks from the '<code>case X:</code>' headers. Case statements not enclosed in
- blocks are NOT indented.</p>
- <div class="code">
- <pre>switch (foo)
- <span class="brace">{</span>
- case 1:
- a += 1;
- break;
- case 2:
- <span class="brace">{</span>
- a += 2;
- break;
- <span class="brace">}</span>
- <span class="brace">}</span>
- </pre>
- <p class="code">
- becomes:</p>
- <pre>switch (foo)
- <span class="brace">{</span>
- case 1:
- a += 1;
- break;
- case 2:
- <span class="brace">{</span>
- a += 2;
- break;
- <span class="brace">}</span>
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_indent-brackets">
- <code class="title">--indent-brackets / -B</code><br />
- Add extra indentation to brackets. This is the option used for Whitesmith and Banner style formatting/indenting.
- If both ‑‑indent‑brackets and ‑‑indent‑blocks are used the result will be
- ‑‑indent‑blocks. This option will be ignored if used with a predefined style.</p>
- <div class="code">
- <pre>if (isFoo)
- <span class="brace">{</span>
- bar();
- <span class="brace">}</span>
- else
- anotherBar();
- </pre>
- <p class="code">
- becomes:</p>
- <pre>if (isFoo)
- <span class="brace">{</span>
- bar();
- <span class="brace">}</span>
- else
- anotherBar();
- </pre>
- </div>
- <p>
- </p>
- <p id="_indent-blocks">
- <code class="title">--indent-blocks / -G</code><br />
- Add extra indentation to blocks <strong>within a function</strong>. The opening bracket for namespaces, classes,
- and functions is not indented. This is the option used for GNU style formatting/indenting. This option will be
- ignored if used with a predefined style.</p>
- <div class="code">
- <pre>if (isFoo)
- <span class="brace">{</span>
- bar();
- <span class="brace">}</span>
- else
- anotherBar();
- </pre>
- <p class="code">
- becomes:</p>
- <pre>if (isFoo)
- <span class="brace">{</span>
- bar();
- <span class="brace">}</span>
- else
- anotherBar();
- </pre>
- </div>
- <p>
- </p>
- <p id="_indent-namespaces">
- <code class="title">--indent-namespaces / -N</code><br />
- Add extra indentation to namespace blocks. This option has no effect on Java files.</p>
- <div class="code">
- <pre>namespace foospace
- <span class="brace">{</span>
- class Foo
- <span class="brace">{</span>
- public:
- Foo();
- virtual ~Foo();
- <span class="brace">}</span>;
- <span class="brace">}</span>
- </pre>
- <p class="code">
- becomes:</p>
- <pre>namespace foospace
- <span class="brace">{</span>
- class Foo
- <span class="brace">{</span>
- public:
- Foo();
- virtual ~Foo();
- <span class="brace">}</span>;
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_indent-labels">
- <code class="title">--indent-labels / -L</code><br />
- Add extra indentation to labels so they appear 1 indent less than the current indentation, rather than being flushed
- to the left (the default).</p>
- <div class="code">
- <pre>void Foo() <span class="brace">{</span>
- while (isFoo) <span class="brace">{</span>
- if (isFoo)
- goto error;
- ...
- error:
- ...
- <span class="brace">}</span>
- <span class="brace">}</span>
- </pre>
- <p class="code">
- becomes (with indented 'error:'):</p>
- <pre>void Foo() <span class="brace">{</span>
- while (isFoo) <span class="brace">{</span>
- if (isFoo)
- goto error;
- ...
- error:
- ...
- <span class="brace">}</span>
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_indent-preprocessor">
- <code class="title">--indent-preprocessor / -w</code><br />
- Indent multi-line preprocessor definitions ending with a backslash. Should be used with --convert-tabs for proper
- results. Does a pretty good job, but cannot perform miracles in obfuscated preprocessor definitions. Without this
- option the preprocessor statements remain unchanged.</p>
- <div class="code">
- <pre>#define Is_Bar(arg,a,b) \
- (Is_Foo((arg), (a)) \
- || Is_Foo((arg), (b)))
- </pre>
- <p class="code">
- becomes:</p>
- <pre>#define Is_Bar(arg,a,b) \
- (Is_Foo((arg), (a)) \
- || Is_Foo((arg), (b)))
- </pre>
- </div>
- <p>
- </p>
- <p id="_indent-col1-comments">
- <code class="title">--indent-col1-comments / -Y</code><br />
- Indent C++ comments beginning in column one. By default C++ comments beginning in column one are not indented.
- This option will allow the comments to be indented with the code.
- </p>
- <div class="code">
- <pre>void Foo()\n"
- <span class="brace">{</span>
- // comment
- if (isFoo)
- bar();
- <span class="brace">}</span>
- </pre>
- <p class="code">
- becomes:</p>
- <pre>void Foo()\n"
- <span class="brace">{</span>
- // comment
- if (isFoo)
- bar();
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_max-instatement-indent">
- <code class="title">--max-instatement-indent=<span class="option">#</span> / -M<span class="option">#</span></code><br />
- Set the maximum of <span class="option">#</span> spaces to indent a continuation line. The <span class="option">#</span>
- indicates a number of columns and must be less than <strong>80</strong>. If no <span class="option">#</span> is
- set, the default value of <strong>40</strong> will be used. A maximum of less than two indent lengths will be
- ignored. This option will prevent continuation lines from extending too far to the right. Setting a larger value
- will allow the code to be extended further to the right.</p>
- <div class="code">
- <pre>fooArray[] = <span class="brace">{</span> red,
- green,
- blue <span class="brace">}</span>;
- fooFunction(barArg1,
- barArg2,
- barArg3);
- </pre>
- <p class="code">
- becomes (with larger value):</p>
- <pre>fooArray[] = <span class="brace">{</span> red,
- green,
- blue <span class="brace">}</span>;
- fooFunction(barArg1,
- barArg2,
- barArg3);
- </pre>
- </div>
- <p>
- </p>
- <p id="_min-conditional-indent">
- <code class="title">--min-conditional-indent=<span class="option">#</span> / -m<span class="option">#</span></code><br />
- Set the minimal indent that is added when a header is built of multiple lines. This indent helps to easily separate
- the header from the command statements that follow. The value for <span class="option">#</span> indicates a <strong>
- number of indents</strong> and is a minimum value. The indent may be greater to align with the data on the
- previous line.<br />
- The valid values are:<br />
- 0 - no minimal indent. The lines will be aligned with the paren on the preceding line.<br />
- 1 - indent at least one additional indent.<br />
- 2 - indent at least two additional indents.<br />
- 3 - indent at least one-half an additional indent. This is intended for large indents (e.g. 8).<br />
- The default value is <strong>2</strong>, two additional indents.
- </p>
- <div class="code">
- <pre><span class="comment">// default setting makes this non-bracketed code clear</span>
- if (a < b
- || c > d)
- foo++;
- <span class="comment">// but creates an exaggerated indent in this bracketed code</span>
- if (a < b
- || c > d)
- <span class="brace">{</span>
- foo++;
- <span class="brace">}</span>
- </pre>
- <p class="code">
- becomes (when setting <strong><code>--min-conditional-indent=<span class="option">0</span></code></strong>):</p>
- <pre><span class="comment">// setting makes this non-bracketed code less clear</span>
- if (a < b
- || c > d)
- foo++;
- <span class="comment">// but makes this bracketed code clearer</span>
- if (a < b
- || c > d)
- <span class="brace">{</span>
- foo++;
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <hr />
- <!-- * * * * * * * * * * * * * Padding Options * * * * * * * * * * * * * -->
- <h3 id="_Padding_Options">
- Padding Options</h3>
- <p id="_break-blocks">
- <code class="title">--break-blocks / -f</code><br />
- Pad empty lines around header blocks (e.g. '<code>if</code>', '<code>for</code>', '<code>while</code>'...).</p>
- <div class="code">
- <pre>isFoo = true;
- if (isFoo) <span class="brace">{</span>
- bar();
- <span class="brace">}</span> else <span class="brace">{</span>
- anotherBar();
- <span class="brace">}</span>
- isBar = false;
- </pre>
- <p class="code">
- becomes:</p>
- <pre>isFoo = true;
- if (isFoo) <span class="brace">{</span>
- bar();
- <span class="brace">}</span> else <span class="brace">{</span>
- anotherBar();
- <span class="brace">}</span>
- isBar = false;
- </pre>
- </div>
- <p>
- </p>
- <p id="_break-blocks=all">
- <code class="title">--break-blocks=all / -F</code><br />
- Pad empty lines around header blocks (e.g. '<code>if</code>', '<code>for</code>', '<code>while</code>'...). Treat
- closing header blocks (e.g. '<code>else</code>', '<code>catch</code>') as stand-alone blocks.</p>
- <div class="code">
- <pre>isFoo = true;
- if (isFoo) <span class="brace">{</span>
- bar();
- <span class="brace">}</span> else <span class="brace">{</span>
- anotherBar();
- <span class="brace">}</span>
- isBar = false;
- </pre>
- <p class="code">
- becomes:</p>
- <pre>isFoo = true;
- if (isFoo) <span class="brace">{</span>
- bar();
-
- <span class="brace">}</span> else <span class="brace">{</span>
- anotherBar();
- <span class="brace">}</span>
- isBar = false;
- </pre>
- </div>
- <p>
- </p>
- <p id="_pad-oper">
- <code class="title">--pad-oper / -p </code><br />
- Insert space padding around operators. Any end of line comments will remain in the original column, if possible.
- Note that there is no option to unpad. Once padded, they stay padded.</p>
- <div class="code">
- <pre>if (foo==2)
- a=bar((b-c)*a,d--);
- </pre>
- <p class="code">
- becomes:</p>
- <pre>if (foo == 2)
- a = bar((b - c) * a, d--);
- </pre>
- </div>
- <p>
- </p>
- <p id="_pad-paren">
- <code class="title">--pad-paren / -P </code><br />
- Insert space padding around parenthesis on both the <strong>outside</strong> and the <strong>inside</strong>.
- Any end of line comments will remain in the original column, if possible.</p>
- <div class="code">
- <pre>if (isFoo(a, b))
- bar(a, b);
- </pre>
- <p class="code">
- becomes:</p>
- <pre>if ( isFoo ( a, b ) )
- bar ( a, b );
- </pre>
- </div>
- <p>
- </p>
- <p id="_pad-paren-out">
- <code class="title">--pad-paren-out / -d </code><br />
- Insert space padding around parenthesis on the <strong>outside</strong> only. Any end of line comments will remain
- in the original column, if possible. This can be used with <code>unpad-paren</code> below to remove unwanted spaces.</p>
- <div class="code">
- <pre>if (isFoo(a, b))
- bar(a, b);
- </pre>
- <p class="code">
- becomes:</p>
- <pre>if (isFoo (a, b) )
- bar (a, b);
- </pre>
- </div>
- <p>
- </p>
- <p id="_pad-paren-in">
- <code class="title">--pad-paren-in / -D </code><br />
- Insert space padding around parenthesis on the <strong>inside</strong> only. Any end of line comments will remain
- in the original column, if possible. This can be used with <code>unpad-paren</code> below to remove unwanted spaces.</p>
- <div class="code">
- <pre>if (isFoo(a, b))
- bar(a, b);
- </pre>
- <p class="code">
- becomes:</p>
- <pre>if ( isFoo( a, b ) )
- bar( a, b );
- </pre>
- </div>
- <p>
- </p>
- <p id="_pad-header">
- <code class="title">--pad-header / -H </code><br />
- Insert space padding after paren headers only (e.g. '<code>if</code>', '<code>for</code>', '<code>while</code>'...).
- Any end of line comments will remain in the original column, if possible. This can be used with <code>unpad-paren</code>
- to remove unwanted spaces.</p>
- <div class="code">
- <pre>if(isFoo(a, b))
- bar(a, b);</pre>
- <p class="code">
- becomes:</p>
- <pre>if (isFoo(a, b))
- bar(a, b);
- </pre>
- </div>
- <p>
- </p>
- <p id="_unpad-paren">
- <code class="title">--unpad-paren / -U </code><br />
- Remove extra space padding around parenthesis on the inside and outside. Any end of line comments will remain
- in the original column, if possible. This option can be used in combination with the paren padding options <code>pad‑paren</code>,
- <code>pad‑paren‑out</code>, <code>pad‑paren‑in</code>, and <code>pad‑header</code>
- above. Only padding that has not been requested by other options will be removed.</p>
- <p>
- For example, if a source has parens padded on both the inside and outside, and you want inside only. You need
- to use <code>unpad-paren</code> to remove the outside padding, and <code>pad‑paren‑in</code> to retain
- the inside padding. Using only <code>pad‑paren‑in</code> would not remove the outside padding.</p>
- <div class="code">
- <pre>if ( isFoo( a, b ) )
- bar ( a, b );
- </pre>
- <p class="code">
- becomes (with no padding option requested):</p>
- <pre>if(isFoo(a, b))
- bar(a, b);
- </pre>
- </div>
- <p>
- </p>
- <p id="_delete-empty-lines">
- <code class="title">--delete-empty-lines / -x</code><br />
- Delete empty lines within a function or method. Empty lines outside of functions or methods are NOT deleted. If
- used with break-blocks or break-blocks=all it will delete all lines EXCEPT the lines added by the break-blocks
- options.</p>
- <div class="code">
- <pre>void Foo()
- <span class="brace">{</span>
-
- foo1 = 1;
-
- foo2 = 2;
-
- <span class="brace">}</span>
- </pre>
- <p class="code">
- becomes:</p>
- <pre>void Foo()
- <span class="brace">{</span>
- foo1 = 1;
- foo2 = 2;
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_fill-empty-lines">
- <code class="title">--fill-empty-lines / -E</code><br />
- Fill empty lines with the white space of the previous line.</p>
- <p>
- </p>
- <hr />
- <!-- * * * * * * * * * * * * * Formatting Options * * * * * * * * * * * * * -->
- <h3 id="_Formatting_Options">
- Formatting Options</h3>
- <p id="_break-closing-brackets">
- <code class="title">--break-closing-brackets / -y </code><br />
- When used with --brackets=attach, --brackets=linux, or --brackets=stroustrup, this breaks closing headers (e.g.
- 'else', 'catch', ...) from their immediately preceding closing brackets. Closing header brackets are always broken
- with broken brackets, horstmann brackets, indented blocks, and indented brackets.</p>
- <div class="code">
- <pre>void Foo(bool isFoo) <span class="brace">{</span>
- if (isFoo) <span class="brace">{</span>
- bar();
- <span class="brace">}</span> else <span class="brace">{</span>
- anotherBar();
- <span class="brace">}</span>
- <span class="brace">}</span>
- </pre>
- <p class="code">
- becomes (a broken 'else'):</p>
- <pre>void Foo(bool isFoo) <span class="brace">{</span>
- if (isFoo) <span class="brace">{</span>
- bar();
- <span class="brace">}</span>
- else <span class="brace">{</span>
- anotherBar();
- <span class="brace">}</span>
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_break-elseifs">
- <code class="title">--break-elseifs / -e</code><br />
- Break "else if" header combinations into separate lines. This option has no effect if keep-one-line-statements
- is used, the "else if" statements will remain as they are.</p>
- <p>
- If this option is NOT used, "else if" header combinations will be placed on a single line.</p>
- <div class="code">
- <pre>if (isFoo) <span class="brace">{</span>
- bar();
- <span class="brace">}</span>
- else if (isFoo1()) <span class="brace">{</span>
- bar1();
- <span class="brace">}</span>
- else if (isFoo2()) <span class="brace">}</span>
- bar2;
- <span class="brace">}</span>
- </pre>
- <p class="code">
- becomes:</p>
- <pre>if (isFoo) <span class="brace">{</span>
- bar();
- <span class="brace">}</span>
- else
- if (isFoo1()) <span class="brace">{</span>
- bar1();
- <span class="brace">}</span>
- <span class="brace"> </span> else
- if (isFoo2()) <span class="brace">{</span>
- bar2();
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_add-brackets">
- <code class="title">--add-brackets / -j </code><br />
- Add brackets to unbracketed one line conditional statements (e.g. '<code>if</code>', '<code>for</code>',
- '<code>while</code>'...). The statement must be on a single line. The brackets will be added according to
- the currently requested predefined style or bracket type. If no style or bracket type is requested the brackets
- will be attached. If --add-one-line-brackets is also used the result will be one line brackets.</p>
- <div class="code">
- <pre>if (isFoo)
- isFoo = false;
- </pre>
- <p class="code">
- becomes:</p>
- <pre>if (isFoo) <span class="brace">{</span>
- isFoo = false;
- <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_add-one-line-brackets">
- <code class="title">--add-one-line-brackets / -J </code><br />
- Add one line brackets to unbracketed one line conditional statements (e.g. '<code>if</code>', '<code>for</code>',
- '<code>while</code>'...). The statement must be on a single line. The option implies --keep-one-line-blocks and
- will not break the one line blocks.</p>
- <div class="code">
- <pre>if (isFoo)
- isFoo = false;
- </pre>
- <p class="code">
- becomes:</p>
- <pre>if (isFoo)
- <span class="brace">{</span> isFoo = false; <span class="brace">}</span>
- </pre>
- </div>
- <p>
- </p>
- <p id="_keep-one-line-blocks">
- <code class="title">--keep-one-line-blocks / -O </code><br />
- Don't break one-line blocks.</p>
- <div class="code">
- <pre>if (isFoo)
- <span class="brace">{</span> isFoo = false; cout << isFoo << endl; <span class="brace">}</span>
- </pre>
- <p class="code">
- remains unchanged.</p>
- </div>
- <p>
- </p>
- <p id="_keep-one-line-statements">
- <code class="title">--keep-one-line-statements / -o </code><br />
- Don't break complex statements and multiple statements residing on a single line.</p>
- <div class="code">
- <pre>if (isFoo)
- <span class="brace">{</span>
- isFoo = false; cout << isFoo << endl;
- <span class="brace">}</span>
- </pre>
- <p class="code">
- remains unchanged.</p>
- <pre>if (isFoo) DoBar();
- </pre>
- <p class="code">
- remains unchanged.</p>
- </div>
- <p>
- </p>
- <p id="_convert-tabs">
- <code class="title">--convert-tabs / -c</code><br />
- Converts tabs into spaces in the non-indentation part of the line. The number of spaces inserted will maintain
- the spacing of the tab. The current setting for spaces per tab is used. It may not produce the expected results
- if convert-tabs is used when changing spaces per tab. Tabs are not replaced in quotes.</p>
- <p>
- </p>
- <p id="_align-pointer">
- <code class="title">--align-pointer=type / -k1<br />
- --align-pointer=middle / -k2<br />
- --align-pointer=name / -k3</code><br />
- Attach a pointer or reference operator (* or &) to either the variable type (left) or variable name (right),
- or place it between the type and name. The spacing between the type and name will be preserved, if possible. This
- option is effective for C/C++ files only.</p>
- <div class="code">
- <pre>char *foo1;</pre>
- <p class="code">
- becomes (with align-pointer=type):</p>
- <pre>char* foo1;</pre>
- </div>
- <div class="code">
- <pre>char* foo2;</pre>
- <p class="code">
- becomes (with align-pointer=middle):</p>
- <pre>char * foo2;</pre>
- </div>
- <div class="code">
- <pre>char& foo3;</pre>
- <p class="code">
- becomes (with align-pointer=name):</p>
- <pre>char &foo3;</pre>
- </div>
- <p>
- </p>
- <p id="_mode">
- <code class="title">--mode=c</code><br />
- <code class="title">--mode=cs</code><br />
- <code class="title">--mode=java</code><br />
- Indent a C/C++, C#, or Java file. The option is usually set from the file extension for each file. You can override
- the setting with this entry. It will be used for all files regardless of the file extension. It allows the formatter
- to identify language specific syntax such as C++ classes, templates, and keywords.</p>
- <p>
- </p>
- <hr />
- <!-- * * * * * * * * * * * * * Other Options * * * * * * * * * * * * * -->
- <h3 id="_Other_Options">
- Other Options</h3>
- <p id="_suffix">
- <code class="title">--suffix=<span class="option">####</span></code><br />
- Append the suffix #### instead of '.orig' to original filename (e.g. <code>--suffix=<span class="option">.bak</span></code>).
- If this is to be a file extension, the dot '.' must be included. Otherwise the suffix will be appended to the
- current file extension.</p>
- <p id="_suffix=none">
- <code class="title">--suffix=none / -n</code><br />
- Do not retain a backup of the original file. The original file is purged after it is formatted.</p>
- <p id="_options">
- <code class="title">--options=<span class="option">####</span></code><br />
- Specify an options file #### to read and use. It must contain a file path for the file. This will allow the file
- name to be changed from astylerc or .astylerc. </p>
- <p id="_options=none">
- <code class="title">--options=none</code><br />
- Disable the default options file. Only the command-line parameters will be used.</p>
- <p id="_recursive">
- <code class="title">--recursive / -r / -R</code><br />
- For each directory in the command line, process all subdirectories recursively. When using the recursive option
- the file name statement should contain a wildcard. Linux users should place the filepath and name in double quotes
- so the shell will not resolve the wildcards (e.g. "$HOME/src/*.cpp"). Windows users should place the filepath
- and name in double quotes if the path or name contains spaces.</p>
- <p id="_exclude">
- <code class="title">--exclude=<span class="option">####</span></code><br />
- Specify a file or sub directory #### to be excluded from processing. </p>
- <p>
- Excludes are matched from the end of the filepath. An exclude option of "templates" will exclude ALL directories
- named "templates". An exclude option of "cpp/templates" will exclude ALL "cpp/templates" directories. You may
- proceed backwards in the directory tree to exclude only the required directories.</p>
- <p>
- Specific files may be excluded in the same manner. An exclude option of "default.cpp" will exclude ALL files named
- "default.cpp". An exclude option of "python/default.cpp" will exclude ALL files named "default.cpp" contained
- in a "python" subdirectory. You may proceed backwards in the directory tree to exclude only the required files.</p>
- <p>
- Wildcards are NOT allowed. There may be more than one exclude statement. The filepath and name may be placed in
- double quotes (e.g. ‑‑exclude="foo bar.cpp").</p>
- <p id="_errors-to-stdout">
- <code class="title">--errors-to-stdout / -X</code><br />
- Print errors to standard-output rather than to standard-error.<br />
- This option should be helpful for systems/shells that do not have this option, such as in Windows95.</p>
- <p id="_preserve-date">
- <code class="title">--preserve-date / -Z</code><br />
- Preserve the original file's date and time modified. The date and time modified will not be changed in the formatted
- file. This option is not effective if redirection is used to rename the input file.</p>
- <p id="_verbose">
- <code class="title">--verbose / -v</code><br />
- Verbose display mode. Display optional information, such as release number and statistical data.</p>
- <p id="_formatted">
- <code class="title">--formatted / -Q</code><br />
- Formatted files display mode. Display only the files that have been formatted. Do not display files that
- are unchanged.</p>
- <p id="_quiet">
- <code class="title">--quiet / -q</code><br />
- Quiet display mode. Suppress all output except error messages.</p>
- <p id="_lineend">
- <code class="title">--lineend=windows / -z1<br />
- --lineend=linux / -z2<br />
- --lineend=macold / -z3</code><br />
- Force use of the specified line end style. Valid options are windows (CRLF), linux (LF), and macold (CR). MacOld
- style is the format for OS 9 and earlier. Mac OS X uses the Linux style. If one of these options is not used the
- line ends will be determined automatically from the input file.</p>
- <p id="_version">
- <code class="title">--version / -V</code><br />
- Print version number and quit. The short option must be by itself, it cannot be concatenated with other options.</p>
- <p id="_help">
- <code class="title">--help / -h / -?</code><br />
- Print a help message and quit. The short option must be by itself, it cannot be concatenated with other options.</p>
- <p>
- </p>
- <hr style="margin-left: -0.4in;" />
- <center class="footer">
- <table width="100%">
- <col width="30%" />
- <col width="40%" />
- <col width="30%" />
- <tr><td align="left"><a href="http://www.gnu.org/copyleft/lesser.html">
- <img src="http://www.gnu.org/graphics/lgplv3-88x31.png" alt="[LGPLv3]" /></a> <a href="http://www.gnu.org/licenses/gpl.html">
- <img src="http://www.gnu.org/graphics/gplv3-88x31.png" alt="[GPLv3]" /></a></td>
- <td align="center" style="color: #0000A0; font-size: x-large; font-weight: bold;">ENJOY !!!</td>
- <td align="right"><a href="http://sourceforge.net/projects/astyle">
- <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=2319&type=15" width="150" height="40" alt="[SourceForge.net]" /></a>
- </td>
- </tr>
- </table>
- </center>
- <p>
- </p>
- <p>
- </p>
- <!-- CUT HERE FOR INSERTION INTO SOURCEFORGE DOC MANAGER -->
- </body>
- </html>
|