astyle.html 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Artistic Style</title>
  5. <meta http-equiv="Content-Language" content="en-us" />
  6. <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
  7. <meta name="description" content="Artistic Style is a source code indenter, source code formatter, and source code beautifier
  8. for the C, C++, C# and Java programming languages." />
  9. <meta name="keywords" content="artistic style, astyle, source code indenter, source code formatter, source code beautifier" />
  10. <link href="styles.css" rel="stylesheet" type="text/css" />
  11. <!-- the following styles are additions to astyle.html -->
  12. <style type="text/css">
  13. code { color:navy; }
  14. code.title { font-size:larger; font-weight:bold; }
  15. p.code { margin-left:0.3in; }
  16. pre { color:navy; font-weight:bold; }
  17. span.brace { color:red; }
  18. span.comment { color:#696969; } /*dimgray*/
  19. span.option { color:#8B4513; } /*saddlebrown*/
  20. hr { margin-left:-0.4in }
  21. </style>
  22. </head>
  23. <body>
  24. <!-- CUT HERE FOR INSERTION INTO SOURCEFORGE DOC MANAGER -->
  25. <h1>
  26. Artistic Style 2.01</h1>
  27. <h2>
  28. A Free, Fast and Small Automatic Formatter<br />
  29. for C, C++, C#, and Java Source Code</h2>
  30. <h3 id="Contents">
  31. Contents</h3>
  32. <p class="contents1">
  33. <a class="contents" href="#_General_Information">General&nbsp;Information</a></p>
  34. <p class="contents1">
  35. <a class="contents" href="#_Usage">Usage</a></p>
  36. <p class="contents1">
  37. <a class="contents" href="#_Options">Options</a></p>
  38. <p class="contents1">
  39. <a class="contents" href="#_Options_File">Options&nbsp;File</a></p>
  40. <p class="contents1">
  41. <a class="contents" href="#_Predefined_Style_Options">Predefined&nbsp;Style&nbsp;Options</a></p>
  42. <p class="contents2">
  43. <a class="contents" href="#_style=allman">style=allman</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_style=java">
  44. style=java</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_style=k&r">style=k&r</a>&nbsp;&nbsp;&nbsp; <a class="contents"
  45. href="#_style=stroustrup">style=stroustrup</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_style=whitesmith">style=whitesmith</a>&nbsp;&nbsp;&nbsp;
  46. <a class="contents" href="#_style=banner">style=banner</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_style=gnu">
  47. style=gnu</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_style=linux">style=linux</a>&nbsp;&nbsp;&nbsp;
  48. <a class="contents" href="#_style=horstmann">style=horstmann</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_style=1tbs">
  49. style=1tbs</a>&nbsp;&nbsp;&nbsp;
  50. </p>
  51. <p class="contents1">
  52. <a class="contents" href="#_Tab_and_Bracket_Options">Tab&nbsp;and&nbsp;Bracket&nbsp;Options</a>
  53. </p>
  54. <p class="contents2">
  55. <a class="contents" href="#_default_indent">default indent</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_indent=spaces">
  56. indent=spaces</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_indent=tab">indent=tab</a>&nbsp;&nbsp;&nbsp;
  57. <a class="contents" href="#_indent=force-tab">indent=force&#8209;tab</a>&nbsp;&nbsp;&nbsp; <a class="contents"
  58. href="#_default_brackets">default&nbsp;brackets</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_brackets=break">
  59. brackets=break</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_brackets=attach">brackets=attach</a>&nbsp;&nbsp;&nbsp;
  60. <a class="contents" href="#_brackets=linux">brackets=linux</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_brackets=stroustrup">
  61. brackets=stroustrup</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_brackets=horstmann">brackets=horstmann</a>&nbsp;&nbsp;&nbsp;
  62. </p>
  63. <p class="contents1">
  64. <a class="contents" href="#_Indentation_Options">Indentation&nbsp;Options</a></p>
  65. <p class="contents2">
  66. <a class="contents" href="#_indent-classes">indent&#8209;classes</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_indent-switches">
  67. indent&#8209;switches</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_indent-cases">indent&#8209;cases</a>&nbsp;&nbsp;&nbsp;
  68. <a class="contents" href="#_indent-brackets">indent&#8209;brackets</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_indent-blocks">
  69. indent&#8209;blocks</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_indent-namespaces">indent&#8209;namespaces</a>&nbsp;&nbsp;&nbsp;
  70. <a class="contents" href="#_indent-labels">indent&#8209;labels</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_indent-preprocessor">
  71. indent&#8209;preprocessor</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_indent-col1-comments">indent&#8209;col1&#8209;comments</a>&nbsp;&nbsp;&nbsp;
  72. <a class="contents" href="#_max-instatement-indent">max&#8209;instatement&#8209;indent</a>&nbsp;&nbsp;&nbsp; <a
  73. class="contents" href="#_min-conditional-indent">min&#8209;conditional&#8209;indent</a>&nbsp;&nbsp;&nbsp;
  74. </p>
  75. <p class="contents1">
  76. <a class="contents" href="#_Padding_Options">Padding&nbsp;Options</a></p>
  77. <p class="contents2">
  78. <a class="contents" href="#_break-blocks">break&#8209;blocks</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_break-blocks=all">
  79. break&#8209;blocks=all</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_pad-oper">pad&#8209;oper</a>&nbsp;&nbsp;&nbsp;
  80. <a class="contents" href="#_pad-paren">pad&#8209;paren</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_pad-paren-out">
  81. pad&#8209;paren&#8209;out</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_pad-paren-in">pad&#8209;paren&#8209;in</a>&nbsp;&nbsp;&nbsp;
  82. <a class="contents" href="#_pad-header">pad&#8209;header</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_unpad-paren">
  83. unpad&#8209;paren</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_delete-empty-lines">delete&#8209;empty&#8209;lines</a>&nbsp;&nbsp;&nbsp;
  84. <a class="contents" href="#_fill-empty-lines">fill&#8209;empty&#8209;lines</a>&nbsp;&nbsp;&nbsp;
  85. </p>
  86. <p class="contents1">
  87. <a class="contents" href="#_Formatting_Options">Formatting&nbsp;Options</a></p>
  88. <p class="contents2">
  89. <a class="contents" href="#_break-closing-brackets">break&#8209;closing&#8209;brackets</a>&nbsp;&nbsp;&nbsp; <a
  90. class="contents" href="#_break-elseifs">break&#8209;elseifs</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_add-brackets">
  91. add&#8209;brackets</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_add-one-line-brackets">add&#8209;one&#8209;line&#8209;brackets</a>&nbsp;&nbsp;&nbsp;
  92. <a class="contents" href="#_keep-one-line-blocks">keep&#8209;one&#8209;line&#8209;blocks</a>&nbsp;&nbsp;&nbsp;
  93. <a class="contents" href="#_keep-one-line-statements">keep&#8209;one&#8209;line&#8209;statements</a>&nbsp;&nbsp;&nbsp;
  94. <a class="contents" href="#_convert-tabs">convert&#8209;tabs</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_align-pointer">
  95. align&#8209;pointer</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_mode">mode</a>&nbsp;&nbsp;&nbsp;
  96. </p>
  97. <p class="contents1">
  98. <a class="contents" href="#_Other_Options">Other&nbsp;Options</a></p>
  99. <p class="contents2">
  100. <a class="contents" href="#_suffix">suffix</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_suffix=none">suffix=none</a>&nbsp;&nbsp;&nbsp;
  101. <a class="contents" href="#_options">options</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_options=none">options=none</a>&nbsp;&nbsp;&nbsp;
  102. <a class="contents" href="#_recursive">recursive</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_exclude">exclude</a>&nbsp;&nbsp;&nbsp;
  103. <a class="contents" href="#_errors-to-stdout">errors&#8209;to&#8209;stdout</a>&nbsp;&nbsp;&nbsp; <a class="contents"
  104. href="#_preserve-date">preserve&#8209;date</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_verbose">verbose</a>&nbsp;&nbsp;&nbsp;
  105. <a class="contents" href="#_formatted">formatted</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_quiet">quiet</a>&nbsp;&nbsp;&nbsp;
  106. <a class="contents" href="#_lineend">lineend</a>&nbsp;&nbsp;&nbsp; <a class="contents" href="#_version">version</a>&nbsp;&nbsp;&nbsp;
  107. <a class="contents" href="#_help">help</a>&nbsp;&nbsp;&nbsp;
  108. </p>
  109. <p>
  110. &nbsp;</p>
  111. <hr />
  112. <!-- * * * * * * * * * * * * General Information< * * * * * * * * * * * * -->
  113. <h3 id="_General_Information">
  114. General Information</h3>
  115. <h4>
  116. Line Endings</h4>
  117. <p>
  118. Line endings in the formatted file will be the same as the input file. If there are mixed line endings the most
  119. frequent occurrence will be used. There is also an option to specify or change the line endings.</p>
  120. <h4>
  121. File Type</h4>
  122. <p>
  123. Artistic Style will determine the file type from the file extension. The extension ".java" indicates a Java file,
  124. and ".cs" indicates a C# file. Everything else is a C or C++ file. If you are using a non-standard file extension
  125. for Java or C#, use one of the <code>--mode=</code> options.</p>
  126. <h4>
  127. Wildcards and Recursion</h4>
  128. <p>
  129. Artistic Style can process directories recursively. Wildcards (such as "*.cpp" or "*.c??") are processed internally.
  130. If a shell is used it should pass the wildcards to Artistic Style instead of resolving them first. For Linux use
  131. double quotes around paths whose filename contains wildcards. For Windows use double quotes around paths whose
  132. filename contains spaces. The "Other Options" section contains information on recursive processing.</p>
  133. <h4>
  134. File Names</h4>
  135. <p>
  136. When a file is formatted, the newly indented file retains the original file name. A copy of the original file
  137. is created with an <code><strong>.orig</strong></code> appended to the original file name. (This can be set to
  138. a different string by the option <code>--suffix=</code>, or suppressed altogether by the options <code>-n</code>
  139. or <code>--suffix=none</code>). Thus, after indenting <code><em>SourceFile.cpp</em></code> the indented file will
  140. 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>
  141. <h4>
  142. Other Considerations</h4>
  143. <p>
  144. Artistic Style can format standard class library statements such as Open GL, wxWidgets, QT, and MFC.</p>
  145. <p>
  146. Embedded assembler language is formatted correctly. This includes extended assembly and Microsoft specific assembler
  147. lines and blocks.</p>
  148. <p>
  149. Artistic Style can format embedded SQL statements. The SQL formatting will be maintained as long as the standard
  150. hanging indent format is used. If the "exec sql" statement is indented more than the following statements, the
  151. SQL will be aligned in a single column.</p>
  152. <p>
  153. Files encoded as UTF&#8209;16 or UTF&#8209;32 will NOT be formatted. These are left unchanged and a warning message
  154. is displayed. Some compilers do not support these encodings. Other compilers must have a Byte-Order-Mark (BOM)
  155. to recognize the encoding. To use Artistic Style the files can be converted to the newer UTF&#8209;8 encoding
  156. with the program iconv. There are Linux and Windows versions available. A sample command line is "iconv &#8209;f
  157. &nbsp;UTF&#8209;16 &#8209;t UTF&#8209;8 filein.cpp &gt;fileout.cpp. Visual Studio can convert the files from the
  158. "File &gt; Advanced Save Options" menu. Select encoding "Unicode (UTF&#8209;8 with signature) - Codepage 65001".
  159. There are other development environments and text editors, such as SciTE, that can convert files to UTF&#8209;8.
  160. </p>
  161. <p>
  162. Embedded statements that are multiple-line and are NOT in a C type format, such as Python, are usually mal-formatted.
  163. (A C type format has blocks enclosed by brackets and statements terminated by a semi-colon). Macros that define
  164. functions may cause the following code to be mal-formatted because the macro is missing the brackets and semi-colons
  165. from the definition. If you have source code with these types of statements, exclude them with the <code>--exclude=</code>
  166. statement described in the "Other Options" section.</p>
  167. <h4>
  168. Quick Start</h4>
  169. <p>
  170. If you have never used Artistic Style there are a couple of ways to start. One is to run it with no options at
  171. all. This will format the file with 4 spaces per indent and will leave the brackets unchanged. Another is to use
  172. one of the predefined styles described in the "Predefined Style Options" section. Select one with a bracket formatting
  173. style you like. Once you are familiar with the options you can customize the format to your personal preference.</p>
  174. <p>
  175. &nbsp;</p>
  176. <hr />
  177. <!-- * * * * * * * * * * * * * * * Usage * * * * * * * * * * * * * * * -->
  178. <h3 id="_Usage">
  179. Usage</h3>
  180. <p>
  181. Artistic style is a console program that receives information from the command line. The format of the command
  182. line is:</p>
  183. <pre>astyle&nbsp; [options]&nbsp; <em>SourceFile1&nbsp; SourceFile2&nbsp; SourceFile3</em>&nbsp; [ . . . ]
  184. </pre>
  185. <p>
  186. The block parens [ ] indicate that more than one option or more than one filename can be entered. They are NOT
  187. actually included in the command. For the options format see the following Options section.</p>
  188. <div class="code">
  189. <p>
  190. &nbsp;&nbsp;Example to format a single file:</p>
  191. <pre>astyle --style=allman /home/user/project/foo.cpp
  192. </pre>
  193. <p>
  194. &nbsp;&nbsp;Example to format all .cpp and .h files recursively:</p>
  195. <pre>astyle --style=allman --recursive /home/user/project/*.cpp /home/user/project/*.h
  196. </pre>
  197. </div>
  198. <p>
  199. Another option will format a single file and change the name:</p>
  200. <pre>astyle [options] &lt; <em>OriginalSourceFile</em> &gt; <em>BeautifiedSourceFile</em>
  201. </pre>
  202. <p>
  203. The <span style="color: #0000a0">&lt;</span> and <span style="color: #0000a0">&gt;</span> characters are used
  204. to redirect the files into standard input (cin) and out of standard output (cout) - don't forget them! With this
  205. option only one file at a time can be formatted. Wildcards are not recognized, there are no console messages,
  206. and a backup is not created.</p>
  207. <p>
  208. &nbsp;</p>
  209. <hr />
  210. <!-- * * * * * * * * * * * * * * * Options * * * * * * * * * * * * * * * -->
  211. <h3 id="_Options">
  212. Options</h3>
  213. <p>
  214. Not specifying any option will result in 4 spaces per indent, no change in bracket placement, and no formatting
  215. changes.</p>
  216. <p>
  217. Options may be written in two different ways.</p>
  218. <h4>
  219. Long options</h4>
  220. <p>
  221. These options start with '<strong>--</strong>', and must be written one at a time.<br />
  222. (Example: '<code>--brackets=attach --indent=spaces=4</code>')</p>
  223. <h4>
  224. Short Options</h4>
  225. <p>
  226. These options start with a single '<strong>-</strong>', and may be concatenated together.<br />
  227. (Example: '<code>-bps4</code>' is the same as writing '<code>-b -p -s4</code>'.)</p>
  228. <p>
  229. &nbsp;</p>
  230. <hr />
  231. <!-- * * * * * * * * * * * * * * Options File * * * * * * * * * * * * * * -->
  232. <h3 id="_Options_File">
  233. Options File</h3>
  234. <p>
  235. An OPTIONAL default options file may be used to supplement or replace the command line options.&nbsp;</p>
  236. <ul>
  237. <li>The command line options have precedence. If there is a conflict between a command line option and an option in
  238. the default options file, the command line option will be used.</li>
  239. <li>Artistic Style looks for this file in the following locations (in order):
  240. <ol>
  241. <li>the file indicated by the --options= command line option;</li>
  242. <li>the file and directory indicated by the environment variable ARTISTIC_STYLE_OPTIONS (if it exists);</li>
  243. <li>the file named .astylerc in the directory pointed to by the HOME environment variable (e.g. "$HOME/.astylerc"
  244. on Linux);</li>
  245. <li>the file named astylerc in the directory pointed to by the USERPROFILE environment variable (e.g. "%USERPROFILE%\astylerc"
  246. on Windows).</li>
  247. </ol>
  248. </li>
  249. <li>This option file lookup can be disabled by specifying --options=none on the command line.</li>
  250. <li>Options may be set apart by new-lines, tabs, commas, or spaces.</li>
  251. <li>Long options in the options file may be written without the preceding '--'.</li>
  252. <li>Lines within the options file that begin with '#' are considered line-comments.</li>
  253. </ul>
  254. <p>
  255. Example of a default options file:</p>
  256. <div class="code">
  257. <pre><span class="comment"># this line is a comment</span>
  258. --brackets=attach <span class="comment"># this is a line-end comment</span>
  259. <span class="comment"># long options can be written without the preceding '--'</span>
  260. indent-switches <span class="comment"># cannot do this on the command line</span>
  261. <span class="comment"># short options must have the preceding '-'</span>
  262. -t -p
  263. <span class="comment"># short options can be concatenated together</span>
  264. -M65Ucv</pre>
  265. </div>
  266. <p>
  267. &nbsp;</p>
  268. <hr />
  269. <!-- * * * * * * * * * * * * Predefined Style Options * * * * * * * * * * * * -->
  270. <h3 id="_Predefined_Style_Options">
  271. Predefined Style Options</h3>
  272. <p>
  273. Predefined Style options define the style by setting other options. The style options always override any individual
  274. option settings. You will always get the requested style regardless of other defined options.</p>
  275. <p>
  276. The predefined style options always set the options brackets=###, indent&#8209;blocks, and indent&#8209;brackets.
  277. These options can NOT be changed with the individual option settings.</p>
  278. <p>
  279. Some styles use the default setting for spaces per indent and some use a different setting. You may use any of
  280. the indent= options with any style. The indent options that do not set the spaces per indent (indent=spaces, indent=tab,
  281. or indent=force&#8209;tab) will use the default spaces per tab setting for the style. The indent options that
  282. set the spaces per indent (indent=spaces=#, indent=tab=#, or indent=force&#8209;tab=#) will use the specified
  283. spaces per tab setting instead of the default for the style. For the options that set the spaces per indent see
  284. the following style descriptions.</p>
  285. <p>
  286. All other options are available to customize the style. By default, none of the styles indent namespaces. This
  287. can be changed with the indent&#8209;namespaces option.</p>
  288. <p>
  289. &nbsp;</p>
  290. <p id="_style=allman">
  291. <code class="title">--style=allman / --style=ansi / --style=bsd / -A1</code><br />
  292. Allman style formatting/indenting uses broken brackets.</p>
  293. <div class="code">
  294. <pre>int Foo(bool isBar)
  295. <span class="brace">{</span>
  296. if (isBar)
  297. <span class="brace">{</span>
  298. bar();
  299. return 1;
  300. <span class="brace">}</span>
  301. else
  302. return 0;
  303. <span class="brace">}</span>
  304. </pre>
  305. </div>
  306. <p>
  307. &nbsp;</p>
  308. <p id="_style=java">
  309. <code class="title">--style=java / -A2</code><br />
  310. Java style formatting/indenting uses attached brackets.</p>
  311. <div class="code">
  312. <pre>int Foo(bool isBar) <span class="brace">{</span>
  313. if (isBar) <span class="brace">{</span>
  314. bar();
  315. return 1;
  316. <span class="brace">}</span> else
  317. return 0;
  318. <span class="brace">}</span>
  319. </pre>
  320. </div>
  321. <p>
  322. &nbsp;</p>
  323. <p id="_style=k&r">
  324. <code class="title">--style=k&amp;r / --style=kr / --style=k/r / -A3</code><br />
  325. Kernighan &amp; Ritchie style formatting/indenting uses linux brackets. Brackets are broken from namespaces, classes,
  326. and function definitions. Brackets are attached to statements within a function.</p>
  327. <p>
  328. Using the k&amp;r option may cause problems because of the &amp;. This can be resolved by enclosing the k&amp;r
  329. in quotes (e.g. &#8209;&#8209;style="k&amp;r") or by using one of the alternates &#8209;&#8209;style=kr or &#8209;&#8209;style=k/r.</p>
  330. <div class="code">
  331. <pre>int Foo(bool isBar)
  332. <span class="brace">{</span>
  333. if (isBar) <span class="brace">{</span>
  334. bar();
  335. return 1;
  336. <span class="brace">}</span> else
  337. return 0;
  338. <span class="brace">}</span>
  339. </pre>
  340. </div>
  341. <p>
  342. &nbsp;</p>
  343. <p id="_style=stroustrup">
  344. <code class="title">--style=stroustrup / -A4</code><br />
  345. Stroustrup style formatting/indenting uses stroustrup brackets. Brackets are broken from function definitions
  346. only. Brackets are attached to namespaces, classes, and statements within a function. <strong>Indentation</strong>
  347. is 5 spaces.
  348. </p>
  349. <div class="code">
  350. <pre>int Foo(bool isBar)
  351. <span class="brace">{</span>
  352. if (isBar) <span class="brace">{</span>
  353. bar();
  354. return 1;
  355. <span class="brace">}</span> else
  356. return 0;
  357. <span class="brace">}</span>
  358. </pre>
  359. </div>
  360. <p>
  361. &nbsp;</p>
  362. <p id="_style=whitesmith">
  363. <code class="title">--style=whitesmith / -A5</code><br />
  364. Whitesmith style formatting/indenting uses broken, indented brackets. Class blocks and switch blocks are indented
  365. to prevent a 'hanging indent' with switch statements and C++ class modifiers (public, private, protected).&nbsp;</p>
  366. <div class="code">
  367. <pre>int Foo(bool isBar)
  368. <span class="brace">{</span>
  369. if (isBar)
  370. <span class="brace">{</span>
  371. bar();
  372. return 1;
  373. <span class="brace">}</span>
  374. else
  375. return 0;
  376. <span class="brace">}</span>
  377. </pre>
  378. </div>
  379. <p>
  380. &nbsp;</p>
  381. <p id="_style=banner">
  382. <code class="title">--style=banner / -A6</code><br />
  383. Banner style formatting/indenting uses attached, indented brackets. Class blocks and switch blocks are indented
  384. to prevent a 'hanging indent' with switch statements and C++ class modifiers (public, private, protected).&nbsp;</p>
  385. <div class="code">
  386. <pre>int Foo(bool isBar) <span class="brace">{</span>
  387. if (isBar) <span class="brace">{</span>
  388. bar();
  389. return 1;
  390. <span class="brace">}</span>
  391. else
  392. return 0;
  393. <span class="brace">}</span>
  394. </pre>
  395. </div>
  396. <p>
  397. &nbsp;</p>
  398. <p id="_style=gnu">
  399. <code class="title">--style=gnu / -A7</code><br />
  400. GNU style formatting/indenting uses broken brackets and indented blocks. <strong>Indentation</strong> is 2 spaces.
  401. </p>
  402. <p>
  403. Extra indentation is added to blocks <strong>within a function</strong>. The opening bracket for namespaces, classes,
  404. and functions is not indented.
  405. </p>
  406. <div class="code">
  407. <pre>int Foo(bool isBar)
  408. <span class="brace">{</span>
  409. if (isBar)
  410. <span class="brace">{</span>
  411. bar();
  412. return 1;
  413. <span class="brace">}</span>
  414. else
  415. return 0;
  416. <span class="brace">}</span>
  417. </pre>
  418. </div>
  419. <p>
  420. &nbsp;</p>
  421. <p id="_style=linux">
  422. <code class="title">--style=linux / -A8</code><br />
  423. Linux style formatting/indenting uses linux style brackets. Brackets are broken from namespace, class, and function
  424. definitions. Brackets are attached to statements within a function. <strong>Indentation</strong> is 8 spaces.
  425. <strong>Minimum conditional indent</strong> is 4 spaces, or one-half the spaces per indent if a different setting
  426. is used. If you want to change the spaces per indent for this style it will be easier to use the K&amp;R style
  427. instead.</p>
  428. <p>
  429. Also known as Kernel Normal Form (KNF) style, this is the style used in the Linux kernel.</p>
  430. <div class="code">
  431. <pre>int Foo(bool isBar)
  432. <span class="brace">{</span>
  433. if (isFoo) <span class="brace">{</span>
  434. bar();
  435. return 1;
  436. <span class="brace">}</span> else
  437. return 0;
  438. <span class="brace">}</span>
  439. </pre>
  440. </div>
  441. <p>
  442. &nbsp;</p>
  443. <p id="_style=horstmann">
  444. <code class="title">--style=horstmann / -A9</code><br />
  445. Horstmann style formatting/indenting uses horstmann style brackets. Brackets are broken with run-in statements.
  446. Switches are indented. <strong>Indentation</strong> is 3 spaces.
  447. </p>
  448. <div class="code">
  449. <pre>int Foo(bool isBar)
  450. <span class="brace">{</span> if (isBar)
  451. <span class="brace">{</span> bar();
  452. return 1;
  453. <span class="brace">} </span>else
  454. return 0;
  455. <span class="brace">}</span>
  456. </pre>
  457. </div>
  458. <p>
  459. &nbsp;</p>
  460. <p id="_style=1tbs">
  461. <code class="title">--style=1tbs / --style=otbs / -A10</code><br />
  462. "One True Brace Style" formatting/indenting uses linux style brackets and adds brackets to unbracketed one line
  463. conditional statements. In the following example brackets have been added to the "<code>return 0;</code>" statement.
  464. The option &#8209;&#8209;add&#8209;one&#8209;line&#8209;brackets can also be used with this style.</p>
  465. <div class="code">
  466. <pre>int Foo(bool isBar)
  467. <span class="brace">{</span>
  468. if (isFoo) <span class="brace">{</span>
  469. bar();
  470. return 1;
  471. <span class="brace">}</span> else <span class="brace">{</span>
  472. return 0;
  473. <span class="brace">}</span>
  474. <span class="brace">}</span>
  475. </pre>
  476. </div>
  477. <p>
  478. &nbsp;</p>
  479. <hr />
  480. <!-- * * * * * * * * * * * * Tab and Bracket Options * * * * * * * * * * * * -->
  481. <h3 id="_Tab_and_Bracket_Options">
  482. Tab and Bracket Options</h3>
  483. <p id="_default_indent">
  484. <code class="title">default indent option</code><br />
  485. If no indentation option is set, the default option of 4 spaces will be used (e.g. <code>-s<span class="option">4</span>
  486. --indent=spaces=<span class="option">4</span></code>).</p>
  487. <p id="_indent=spaces">
  488. <code class="title">--indent=spaces / --indent=spaces=<span class="option">#</span> / -s<span class="option">#</span></code><br />
  489. Indent using # spaces per indent (e.g. <code>-s<span class="option">6</span></code> <code>--indent=spaces=<span
  490. class="option">6</span></code>). # must be between 2 and 20. Not specifying # will result in a default of
  491. 4 spaces per indent.</p>
  492. <p id="_indent=tab">
  493. <code class="title">--indent=tab / --indent=tab=<span class="option">#</span> / -t / -t<span class="option">#</span></code><br />
  494. Indent using tab characters. Treat each tab as # spaces (e.g. <code>-t<span class="option">6</span></code> / <code>
  495. --indent=tab=<span class="option">6</span></code>). # must be between 2 and 20. If no # is set, treats tabs
  496. as 4 spaces.</p>
  497. <p id="_indent=force-tab">
  498. <code class="title">--indent=force-tab / --indent=force-tab=<span class="option">#</span> / -T / -T<span class="option">#</span></code><br />
  499. Indent using tab characters. Treat each tab as # spaces (e.g. <code>-T<span class="option">6</span></code> / <code>
  500. --indent=<span lang="en-us">force-</span>tab=<span class="option">6</span></code>). Uses tabs as indents where
  501. <code>&#8209;&#8209;indent=tab</code> prefers to use spaces, such as inside multi-line statements. # must be between
  502. 2 and 20. If no # is set, treats tabs as 4 spaces.</p>
  503. <p id="_default_brackets">
  504. <code class="title">default brackets option</code><br />
  505. If no brackets option is set, the brackets will not be changed.</p>
  506. <p id="_brackets=break">
  507. <code class="title">--brackets=break / -b</code><br />
  508. Break brackets from their pre-block statements ( e.g. Allman / ANSI style ).</p>
  509. <div class="code">
  510. <pre>void Foo(bool isFoo)
  511. <span class="brace">{</span>
  512. if (isFoo)
  513. <span class="brace">{</span>
  514. bar();
  515. <span class="brace">}</span>
  516. else
  517. <span class="brace">{</span>
  518. anotherBar();
  519. <span class="brace">}</span>
  520. <span class="brace">}</span>
  521. </pre>
  522. </div>
  523. <p>
  524. &nbsp;</p>
  525. <p id="_brackets=attach">
  526. <code class="title">--brackets=attach / -a</code><br />
  527. Attach brackets to their pre-block statements ( e.g. Java style ).</p>
  528. <div class="code">
  529. <pre>void Foo(bool isFoo) <span class="brace">{</span>
  530. if (isFoo) <span class="brace">{</span>
  531. bar();
  532. <span class="brace">}</span> else <span class="brace">{</span>
  533. anotherBar();
  534. <span class="brace">}</span>
  535. <span class="brace">}</span>
  536. </pre>
  537. </div>
  538. <p>
  539. &nbsp;</p>
  540. <p id="_brackets=linux">
  541. <code class="title">--brackets=linux / -l</code><br />
  542. Break brackets from namespace, class, and function definitions, but attach brackets to statements within a function&nbsp;
  543. ( e.g. K&amp;R / Linux style ).</p>
  544. <p>
  545. With C++ files brackets are attached for function definitions within a class (inline class functions). The brackets
  546. are also attached for arrays, structs, enums, and other top level objects that are not classes or functions. This
  547. option is effective for C/C++ files only.</p>
  548. <div class="code">
  549. <pre>void Foo(bool isFoo)
  550. <span class="brace">{</span>
  551. if (isFoo) <span class="brace">{</span>
  552. bar();
  553. <span class="brace">}</span> else <span class="brace">{</span>
  554. anotherBar;
  555. <span class="brace">}</span>
  556. <span class="brace">}</span>
  557. </pre>
  558. </div>
  559. <p>
  560. &nbsp;</p>
  561. <p id="_brackets=stroustrup">
  562. <code class="title">--brackets=stroustrup / -u</code><br />
  563. Break brackets from function definitions only. Attach brackets to namespaces, classes, and statements within a
  564. function ( e.g. Stroustrup style ).</p>
  565. <p>
  566. With C++ files brackets are attached for function definitions within a class (inline class functions). The brackets
  567. are also attached for arrays, structs, enums, and other top level objects that are not classes or functions. This
  568. option is effective for C/C++ files only.</p>
  569. <div class="code">
  570. <pre>void Foo(bool isFoo)
  571. <span class="brace">{</span>
  572. if (isFoo) <span class="brace">{</span>
  573. bar();
  574. <span class="brace">}</span> else <span class="brace">{</span>
  575. anotherBar;
  576. <span class="brace">}</span>
  577. <span class="brace">}</span>
  578. </pre>
  579. </div>
  580. <p>
  581. &nbsp;</p>
  582. <p id="_brackets=horstmann">
  583. <code class="title">--brackets=horstmann / -g</code><br />
  584. Break brackets from their pre-block statements but allow run-in statements on the same line as an opening bracket
  585. ( e.g. Horstmann style ).</p>
  586. <div class="code">
  587. <pre>void Foo(bool isFoo)
  588. <span class="brace">{</span> if (isFoo())
  589. <span class="brace">{</span> bar1();
  590. bar2();
  591. <span class="brace">}</span>
  592. else
  593. <span class="brace">{</span> anotherBar();
  594. <span class="brace">}</span>
  595. <span class="brace">}</span>
  596. </pre>
  597. </div>
  598. <p>
  599. &nbsp;</p>
  600. <hr />
  601. <!-- * * * * * * * * * * * * * Indentation Options * * * * * * * * * * * * * -->
  602. <h3 id="_Indentation_Options">
  603. Indentation Options</h3>
  604. <p id="_indent-classes">
  605. <code class="title">--indent-classes / -C</code><br />
  606. Indent '<code>class</code>' and '<code>struct</code>' blocks so that the blocks '<code>public:</code>', '<code>protected:</code>'
  607. and '<code>private:</code>' are indented. The struct blocks are indented only if an access modifier is declared
  608. somewhere in the struct. The entire block is indented. This option is effective for C++ files only.</p>
  609. <div class="code">
  610. <pre>class Foo
  611. <span class="brace">{</span>
  612. public:
  613. Foo();
  614. virtual ~Foo();
  615. <span class="brace">}</span>;
  616. </pre>
  617. <p class="code">
  618. becomes:</p>
  619. <pre>class Foo
  620. <span class="brace">{</span>
  621. public:
  622. Foo();
  623. virtual ~Foo();
  624. <span class="brace">}</span>;
  625. </pre>
  626. </div>
  627. <p>
  628. &nbsp;</p>
  629. <p id="_indent-switches">
  630. <code class="title">--indent-switches / -S</code><br />
  631. Indent '<code>switch</code>' blocks so that the '<code>case X:</code>' statements are indented in the <code>switch</code>
  632. block. The entire case block is indented.</p>
  633. <div class="code">
  634. <pre>switch (foo)
  635. <span class="brace">{</span>
  636. case 1:
  637. a += 1;
  638. break;
  639. case 2:
  640. <span class="brace">{</span>
  641. a += 2;
  642. break;
  643. <span class="brace">}</span>
  644. <span class="brace">}</span>
  645. </pre>
  646. <p class="code">
  647. becomes:</p>
  648. <pre>switch (foo)
  649. <span class="brace">{</span>
  650. case 1:
  651. a += 1;
  652. break;
  653. case 2:
  654. <span class="brace">{</span>
  655. a += 2;
  656. break;
  657. <span class="brace">}</span>
  658. <span class="brace">}</span>
  659. </pre>
  660. </div>
  661. <p>
  662. &nbsp;</p>
  663. <p id="_indent-cases">
  664. <code class="title">--indent-cases / -K</code><br />
  665. Indent '<code>case X:</code>' blocks from the '<code>case X:</code>' headers. Case statements not enclosed in
  666. blocks are NOT indented.</p>
  667. <div class="code">
  668. <pre>switch (foo)
  669. <span class="brace">{</span>
  670. case 1:
  671. a += 1;
  672. break;
  673. case 2:
  674. <span class="brace">{</span>
  675. a += 2;
  676. break;
  677. <span class="brace">}</span>
  678. <span class="brace">}</span>
  679. </pre>
  680. <p class="code">
  681. becomes:</p>
  682. <pre>switch (foo)
  683. <span class="brace">{</span>
  684. case 1:
  685. a += 1;
  686. break;
  687. case 2:
  688. <span class="brace">{</span>
  689. a += 2;
  690. break;
  691. <span class="brace">}</span>
  692. <span class="brace">}</span>
  693. </pre>
  694. </div>
  695. <p>
  696. &nbsp;</p>
  697. <p id="_indent-brackets">
  698. <code class="title">--indent-brackets / -B</code><br />
  699. Add extra indentation to brackets. This is the option used for Whitesmith and Banner style formatting/indenting.
  700. If both &#8209;&#8209;indent&#8209;brackets and &#8209;&#8209;indent&#8209;blocks are used the result will be
  701. &#8209;&#8209;indent&#8209;blocks. This option will be ignored if used with a predefined style.</p>
  702. <div class="code">
  703. <pre>if (isFoo)
  704. <span class="brace">{</span>
  705. bar();
  706. <span class="brace">}</span>
  707. else
  708. anotherBar();
  709. </pre>
  710. <p class="code">
  711. becomes:</p>
  712. <pre>if (isFoo)
  713. <span class="brace">{</span>
  714. bar();
  715. <span class="brace">}</span>
  716. else
  717. anotherBar();
  718. </pre>
  719. </div>
  720. <p>
  721. &nbsp;</p>
  722. <p id="_indent-blocks">
  723. <code class="title">--indent-blocks / -G</code><br />
  724. Add extra indentation to blocks <strong>within a function</strong>. The opening bracket for namespaces, classes,
  725. and functions is not indented. This is the option used for GNU style formatting/indenting. This option will be
  726. ignored if used with a predefined style.</p>
  727. <div class="code">
  728. <pre>if (isFoo)
  729. <span class="brace">{</span>
  730. bar();
  731. <span class="brace">}</span>
  732. else
  733. anotherBar();
  734. </pre>
  735. <p class="code">
  736. becomes:</p>
  737. <pre>if (isFoo)
  738. <span class="brace">{</span>
  739. bar();
  740. <span class="brace">}</span>
  741. else
  742. anotherBar();
  743. </pre>
  744. </div>
  745. <p>
  746. &nbsp;</p>
  747. <p id="_indent-namespaces">
  748. <code class="title">--indent-namespaces / -N</code><br />
  749. Add extra indentation to namespace blocks. This option has no effect on Java files.</p>
  750. <div class="code">
  751. <pre>namespace foospace
  752. <span class="brace">{</span>
  753. class Foo
  754. <span class="brace">{</span>
  755. public:
  756. Foo();
  757. virtual ~Foo();
  758. <span class="brace">}</span>;
  759. <span class="brace">}</span>
  760. </pre>
  761. <p class="code">
  762. becomes:</p>
  763. <pre>namespace foospace
  764. <span class="brace">{</span>
  765. class Foo
  766. <span class="brace">{</span>
  767. public:
  768. Foo();
  769. virtual ~Foo();
  770. <span class="brace">}</span>;
  771. <span class="brace">}</span>
  772. </pre>
  773. </div>
  774. <p>
  775. &nbsp;</p>
  776. <p id="_indent-labels">
  777. <code class="title">--indent-labels / -L</code><br />
  778. Add extra indentation to labels so they appear 1 indent less than the current indentation, rather than being flushed
  779. to the left (the default).</p>
  780. <div class="code">
  781. <pre>void Foo() <span class="brace">{</span>
  782. while (isFoo) <span class="brace">{</span>
  783. if (isFoo)
  784. goto error;
  785. ...
  786. error:
  787. ...
  788. <span class="brace">}</span>
  789. <span class="brace">}</span>
  790. </pre>
  791. <p class="code">
  792. becomes (with indented 'error:'):</p>
  793. <pre>void Foo() <span class="brace">{</span>
  794. while (isFoo) <span class="brace">{</span>
  795. if (isFoo)
  796. goto error;
  797. ...
  798. error:
  799. ...
  800. <span class="brace">}</span>
  801. <span class="brace">}</span>
  802. </pre>
  803. </div>
  804. <p>
  805. &nbsp;</p>
  806. <p id="_indent-preprocessor">
  807. <code class="title">--indent-preprocessor / -w</code><br />
  808. Indent multi-line preprocessor definitions ending with a backslash. Should be used with --convert-tabs for proper
  809. results. Does a pretty good job, but cannot perform miracles in obfuscated preprocessor definitions. Without this
  810. option the preprocessor statements remain unchanged.</p>
  811. <div class="code">
  812. <pre>#define Is_Bar(arg,a,b) \
  813. (Is_Foo((arg), (a)) \
  814. || Is_Foo((arg), (b)))
  815. </pre>
  816. <p class="code">
  817. becomes:</p>
  818. <pre>#define Is_Bar(arg,a,b) \
  819. (Is_Foo((arg), (a)) \
  820. || Is_Foo((arg), (b)))
  821. </pre>
  822. </div>
  823. <p>
  824. &nbsp;</p>
  825. <p id="_indent-col1-comments">
  826. <code class="title">--indent-col1-comments / -Y</code><br />
  827. Indent C++ comments beginning in column one. By default C++ comments beginning in column one are not indented.
  828. This option will allow the comments to be indented with the code.
  829. </p>
  830. <div class="code">
  831. <pre>void Foo()\n"
  832. <span class="brace">{</span>
  833. // comment
  834. if (isFoo)
  835. bar();
  836. <span class="brace">}</span>
  837. </pre>
  838. <p class="code">
  839. becomes:</p>
  840. <pre>void Foo()\n"
  841. <span class="brace">{</span>
  842. // comment
  843. if (isFoo)
  844. bar();
  845. <span class="brace">}</span>
  846. </pre>
  847. </div>
  848. <p>
  849. &nbsp;</p>
  850. <p id="_max-instatement-indent">
  851. <code class="title">--max-instatement-indent=<span class="option">#</span> / -M<span class="option">#</span></code><br />
  852. Set the &nbsp;maximum of <span class="option">#</span> spaces to indent a continuation line. The &nbsp;<span class="option">#</span>
  853. indicates a number of columns and must be less than <strong>80</strong>. If no <span class="option">#</span> is
  854. set, the default value of <strong>40</strong> will be used. A maximum of less than two indent lengths will be
  855. ignored. This option will prevent continuation lines from extending too far to the right. Setting a larger value
  856. will allow the code to be extended further to the right.</p>
  857. <div class="code">
  858. <pre>fooArray[] = <span class="brace">{</span> red,
  859. green,
  860. blue <span class="brace">}</span>;
  861. fooFunction(barArg1,
  862. barArg2,
  863. barArg3);
  864. </pre>
  865. <p class="code">
  866. becomes (with larger value):</p>
  867. <pre>fooArray[] = <span class="brace">{</span> red,
  868. green,
  869. blue <span class="brace">}</span>;
  870. fooFunction(barArg1,
  871. barArg2,
  872. barArg3);
  873. </pre>
  874. </div>
  875. <p>
  876. &nbsp;</p>
  877. <p id="_min-conditional-indent">
  878. <code class="title">--min-conditional-indent=<span class="option">#</span> / -m<span class="option">#</span></code><br />
  879. Set the minimal indent that is added when a header is built of multiple lines. This indent helps to easily separate
  880. the header from the command statements that follow. The value for <span class="option">#</span> indicates a <strong>
  881. number of indents</strong> and is a minimum value. The indent may be greater to align with the data on the
  882. previous line.<br />
  883. The valid values are:<br />
  884. 0 - no minimal indent. The lines will be aligned with the paren on the preceding line.<br />
  885. 1 - indent at least one additional indent.<br />
  886. 2 - indent at least two additional indents.<br />
  887. 3 - indent at least one-half an additional indent. This is intended for large indents (e.g. 8).<br />
  888. The default value is <strong>2</strong>, two additional indents.
  889. </p>
  890. <div class="code">
  891. <pre><span class="comment">// default setting makes this non-bracketed code clear</span>
  892. if (a &lt; b
  893. || c &gt; d)
  894. foo++;
  895. <span class="comment">// but creates an exaggerated indent in this bracketed code</span>
  896. if (a &lt; b
  897. || c &gt; d)
  898. <span class="brace">{</span>
  899. foo++;
  900. <span class="brace">}</span>
  901. </pre>
  902. <p class="code">
  903. becomes (when setting <strong><code>--min-conditional-indent=<span class="option">0</span></code></strong>):</p>
  904. <pre><span class="comment">// setting makes this non-bracketed code less clear</span>
  905. if (a &lt; b
  906. || c &gt; d)
  907. foo++;
  908. <span class="comment">// but makes this bracketed code clearer</span>
  909. if (a &lt; b
  910. || c &gt; d)
  911. <span class="brace">{</span>
  912. foo++;
  913. <span class="brace">}</span>
  914. </pre>
  915. </div>
  916. <p>
  917. &nbsp;</p>
  918. <hr />
  919. <!-- * * * * * * * * * * * * * Padding Options * * * * * * * * * * * * * -->
  920. <h3 id="_Padding_Options">
  921. Padding Options</h3>
  922. <p id="_break-blocks">
  923. <code class="title">--break-blocks / -f</code><br />
  924. Pad empty lines around header blocks (e.g. '<code>if</code>', '<code>for</code>', '<code>while</code>'...).</p>
  925. <div class="code">
  926. <pre>isFoo = true;
  927. if (isFoo) <span class="brace">{</span>
  928. bar();
  929. <span class="brace">}</span> else <span class="brace">{</span>
  930. anotherBar();
  931. <span class="brace">}</span>
  932. isBar = false;
  933. </pre>
  934. <p class="code">
  935. becomes:</p>
  936. <pre>isFoo = true;
  937. if (isFoo) <span class="brace">{</span>
  938. bar();
  939. <span class="brace">}</span> else <span class="brace">{</span>
  940. anotherBar();
  941. <span class="brace">}</span>
  942. isBar = false;
  943. </pre>
  944. </div>
  945. <p>
  946. &nbsp;</p>
  947. <p id="_break-blocks=all">
  948. <code class="title">--break-blocks=all / -F</code><br />
  949. Pad empty lines around header blocks (e.g. '<code>if</code>', '<code>for</code>', '<code>while</code>'...). Treat
  950. closing header blocks (e.g. '<code>else</code>', '<code>catch</code>') as stand-alone blocks.</p>
  951. <div class="code">
  952. <pre>isFoo = true;
  953. if (isFoo) <span class="brace">{</span>
  954. bar();
  955. <span class="brace">}</span> else <span class="brace">{</span>
  956. anotherBar();
  957. <span class="brace">}</span>
  958. isBar = false;
  959. </pre>
  960. <p class="code">
  961. becomes:</p>
  962. <pre>isFoo = true;
  963. if (isFoo) <span class="brace">{</span>
  964. bar();
  965. <span class="brace">}</span> else <span class="brace">{</span>
  966. anotherBar();
  967. <span class="brace">}</span>
  968. isBar = false;
  969. </pre>
  970. </div>
  971. <p>
  972. &nbsp;</p>
  973. <p id="_pad-oper">
  974. <code class="title">--pad-oper / -p </code><br />
  975. Insert space padding around operators. Any end of line comments will remain in the original column, if possible.
  976. Note that there is no option to unpad. Once padded, they stay padded.</p>
  977. <div class="code">
  978. <pre>if (foo==2)
  979. a=bar((b-c)*a,d--);
  980. </pre>
  981. <p class="code">
  982. becomes:</p>
  983. <pre>if (foo == 2)
  984. a = bar((b - c) * a, d--);
  985. </pre>
  986. </div>
  987. <p>
  988. &nbsp;</p>
  989. <p id="_pad-paren">
  990. <code class="title">--pad-paren / -P </code><br />
  991. Insert space padding around parenthesis on both the <strong>outside</strong> and the <strong>inside</strong>.
  992. Any end of line comments will remain in the original column, if possible.</p>
  993. <div class="code">
  994. <pre>if (isFoo(a, b))
  995. bar(a, b);
  996. </pre>
  997. <p class="code">
  998. becomes:</p>
  999. <pre>if ( isFoo ( a, b ) )
  1000. bar ( a, b );
  1001. </pre>
  1002. </div>
  1003. <p>
  1004. &nbsp;</p>
  1005. <p id="_pad-paren-out">
  1006. <code class="title">--pad-paren-out / -d </code><br />
  1007. Insert space padding around parenthesis on the <strong>outside</strong> only. Any end of line comments will remain
  1008. in the original column, if possible. This can be used with <code>unpad-paren</code> below to remove unwanted spaces.</p>
  1009. <div class="code">
  1010. <pre>if (isFoo(a, b))
  1011. bar(a, b);
  1012. </pre>
  1013. <p class="code">
  1014. becomes:</p>
  1015. <pre>if (isFoo (a, b) )
  1016. bar (a, b);
  1017. </pre>
  1018. </div>
  1019. <p>
  1020. &nbsp;</p>
  1021. <p id="_pad-paren-in">
  1022. <code class="title">--pad-paren-in / -D </code><br />
  1023. Insert space padding around parenthesis on the <strong>inside</strong> only. Any end of line comments will remain
  1024. in the original column, if possible. This can be used with <code>unpad-paren</code> below to remove unwanted spaces.</p>
  1025. <div class="code">
  1026. <pre>if (isFoo(a, b))
  1027. bar(a, b);
  1028. </pre>
  1029. <p class="code">
  1030. becomes:</p>
  1031. <pre>if ( isFoo( a, b ) )
  1032. bar( a, b );
  1033. </pre>
  1034. </div>
  1035. <p>
  1036. &nbsp;</p>
  1037. <p id="_pad-header">
  1038. <code class="title">--pad-header / -H </code><br />
  1039. Insert space padding after paren headers only (e.g. '<code>if</code>', '<code>for</code>', '<code>while</code>'...).
  1040. Any end of line comments will remain in the original column, if possible. This can be used with <code>unpad-paren</code>
  1041. to remove unwanted spaces.</p>
  1042. <div class="code">
  1043. <pre>if(isFoo(a, b))
  1044. bar(a, b);</pre>
  1045. <p class="code">
  1046. becomes:</p>
  1047. <pre>if (isFoo(a, b))
  1048. bar(a, b);
  1049. </pre>
  1050. </div>
  1051. <p>
  1052. &nbsp;</p>
  1053. <p id="_unpad-paren">
  1054. <code class="title">--unpad-paren / -U </code><br />
  1055. Remove extra space padding around parenthesis on the inside and outside. Any end of line comments will remain
  1056. in the original column, if possible. This option can be used in combination with the paren padding options <code>pad&#8209;paren</code>,
  1057. <code>pad&#8209;paren&#8209;out</code>, <code>pad&#8209;paren&#8209;in</code>, and <code>pad&#8209;header</code>
  1058. above. Only padding that has not been requested by other options will be removed.</p>
  1059. <p>
  1060. For example, if a source has parens padded on both the inside and outside, and you want inside only. You need
  1061. to use <code>unpad-paren</code> to remove the outside padding, and <code>pad&#8209;paren&#8209;in</code> to retain
  1062. the inside padding. Using only <code>pad&#8209;paren&#8209;in</code> would not remove the outside padding.</p>
  1063. <div class="code">
  1064. <pre>if ( isFoo( a, b ) )
  1065. bar ( a, b );
  1066. </pre>
  1067. <p class="code">
  1068. becomes (with no padding option requested):</p>
  1069. <pre>if(isFoo(a, b))
  1070. bar(a, b);
  1071. </pre>
  1072. </div>
  1073. <p>
  1074. &nbsp;</p>
  1075. <p id="_delete-empty-lines">
  1076. <code class="title">--delete-empty-lines / -x</code><br />
  1077. Delete empty lines within a function or method. Empty lines outside of functions or methods are NOT deleted. If
  1078. used with break-blocks or break-blocks=all it will delete all lines EXCEPT the lines added by the break-blocks
  1079. options.</p>
  1080. <div class="code">
  1081. <pre>void Foo()
  1082. <span class="brace">{</span>
  1083. foo1 = 1;
  1084. foo2 = 2;
  1085. <span class="brace">}</span>
  1086. </pre>
  1087. <p class="code">
  1088. becomes:</p>
  1089. <pre>void Foo()
  1090. <span class="brace">{</span>
  1091. foo1 = 1;
  1092. foo2 = 2;
  1093. <span class="brace">}</span>
  1094. </pre>
  1095. </div>
  1096. <p>
  1097. &nbsp;</p>
  1098. <p id="_fill-empty-lines">
  1099. <code class="title">--fill-empty-lines / -E</code><br />
  1100. Fill empty lines with the white space of the previous line.</p>
  1101. <p>
  1102. &nbsp;</p>
  1103. <hr />
  1104. <!-- * * * * * * * * * * * * * Formatting Options * * * * * * * * * * * * * -->
  1105. <h3 id="_Formatting_Options">
  1106. Formatting Options</h3>
  1107. <p id="_break-closing-brackets">
  1108. <code class="title">--break-closing-brackets / -y </code><br />
  1109. When used with --brackets=attach, --brackets=linux, or --brackets=stroustrup, this breaks closing headers (e.g.
  1110. 'else', 'catch', ...) from their immediately preceding closing brackets. Closing header brackets are always broken
  1111. with broken brackets, horstmann brackets, indented blocks, and indented brackets.</p>
  1112. <div class="code">
  1113. <pre>void Foo(bool isFoo) <span class="brace">{</span>
  1114. if (isFoo) <span class="brace">{</span>
  1115. bar();
  1116. <span class="brace">}</span> else <span class="brace">{</span>
  1117. anotherBar();
  1118. <span class="brace">}</span>
  1119. <span class="brace">}</span>
  1120. </pre>
  1121. <p class="code">
  1122. becomes (a broken 'else'):</p>
  1123. <pre>void Foo(bool isFoo) <span class="brace">{</span>
  1124. if (isFoo) <span class="brace">{</span>
  1125. bar();
  1126. <span class="brace">}</span>
  1127. else <span class="brace">{</span>
  1128. anotherBar();
  1129. <span class="brace">}</span>
  1130. <span class="brace">}</span>
  1131. </pre>
  1132. </div>
  1133. <p>
  1134. &nbsp;</p>
  1135. <p id="_break-elseifs">
  1136. <code class="title">--break-elseifs / -e</code><br />
  1137. Break "else if" header combinations into separate lines. This option has no effect if keep-one-line-statements
  1138. is used, the "else if" statements will remain as they are.</p>
  1139. <p>
  1140. If this option is NOT used, "else if" header combinations will be placed on a single line.</p>
  1141. <div class="code">
  1142. <pre>if (isFoo) <span class="brace">{</span>
  1143. bar();
  1144. <span class="brace">}</span>
  1145. else if (isFoo1()) <span class="brace">{</span>
  1146. bar1();
  1147. <span class="brace">}</span>
  1148. else if (isFoo2()) <span class="brace">}</span>
  1149. bar2;
  1150. <span class="brace">}</span>
  1151. </pre>
  1152. <p class="code">
  1153. becomes:</p>
  1154. <pre>if (isFoo) <span class="brace">{</span>
  1155. bar();
  1156. <span class="brace">}</span>
  1157. else
  1158. if (isFoo1()) <span class="brace">{</span>
  1159. bar1();
  1160. <span class="brace">}</span>
  1161. <span class="brace"> </span> else
  1162. if (isFoo2()) <span class="brace">{</span>
  1163. bar2();
  1164. <span class="brace">}</span>
  1165. </pre>
  1166. </div>
  1167. <p>
  1168. &nbsp;</p>
  1169. <p id="_add-brackets">
  1170. <code class="title">--add-brackets / -j </code><br />
  1171. Add brackets to unbracketed one line conditional statements&nbsp; (e.g. '<code>if</code>', '<code>for</code>',
  1172. '<code>while</code>'...). The statement must be on a single line.&nbsp;The brackets will be added according to
  1173. the currently requested predefined style or bracket type. If no style or bracket type is requested the brackets
  1174. will be attached. If --add-one-line-brackets is also used the result will be one line brackets.</p>
  1175. <div class="code">
  1176. <pre>if (isFoo)
  1177. isFoo = false;
  1178. </pre>
  1179. <p class="code">
  1180. becomes:</p>
  1181. <pre>if (isFoo) <span class="brace">{</span>
  1182. isFoo = false;
  1183. <span class="brace">}</span>
  1184. </pre>
  1185. </div>
  1186. <p>
  1187. &nbsp;</p>
  1188. <p id="_add-one-line-brackets">
  1189. <code class="title">--add-one-line-brackets / -J </code><br />
  1190. Add one line brackets to unbracketed one line conditional statements&nbsp; (e.g. '<code>if</code>', '<code>for</code>',
  1191. '<code>while</code>'...). The statement must be on a single line. The option implies --keep-one-line-blocks and
  1192. will not break the one line blocks.</p>
  1193. <div class="code">
  1194. <pre>if (isFoo)
  1195. isFoo = false;
  1196. </pre>
  1197. <p class="code">
  1198. becomes:</p>
  1199. <pre>if (isFoo)
  1200. <span class="brace">{</span> isFoo = false; <span class="brace">}</span>
  1201. </pre>
  1202. </div>
  1203. <p>
  1204. &nbsp;</p>
  1205. <p id="_keep-one-line-blocks">
  1206. <code class="title">--keep-one-line-blocks / -O </code><br />
  1207. Don't break one-line blocks.</p>
  1208. <div class="code">
  1209. <pre>if (isFoo)
  1210. <span class="brace">{</span> isFoo = false; cout &lt;&lt; isFoo &lt;&lt; endl; <span class="brace">}</span>
  1211. </pre>
  1212. <p class="code">
  1213. remains unchanged.</p>
  1214. </div>
  1215. <p>
  1216. &nbsp;</p>
  1217. <p id="_keep-one-line-statements">
  1218. <code class="title">--keep-one-line-statements / -o </code><br />
  1219. Don't break complex statements and multiple statements residing on a single line.</p>
  1220. <div class="code">
  1221. <pre>if (isFoo)
  1222. <span class="brace">{</span>
  1223. isFoo = false; cout &lt;&lt; isFoo &lt;&lt; endl;
  1224. <span class="brace">}</span>
  1225. </pre>
  1226. <p class="code">
  1227. remains unchanged.</p>
  1228. <pre>if (isFoo) DoBar();
  1229. </pre>
  1230. <p class="code">
  1231. remains unchanged.</p>
  1232. </div>
  1233. <p>
  1234. &nbsp;</p>
  1235. <p id="_convert-tabs">
  1236. <code class="title">--convert-tabs / -c</code><br />
  1237. Converts tabs into spaces in the non-indentation part of the line. The number of spaces inserted will maintain
  1238. the spacing of the tab. The current setting for spaces per tab is used. It may not produce the expected results
  1239. if convert-tabs is used when changing spaces per tab. Tabs are not replaced in quotes.</p>
  1240. <p>
  1241. &nbsp;</p>
  1242. <p id="_align-pointer">
  1243. <code class="title">--align-pointer=type&nbsp;&nbsp; / -k1<br />
  1244. --align-pointer=middle / -k2<br />
  1245. --align-pointer=name&nbsp;&nbsp; / -k3</code><br />
  1246. Attach a pointer or reference operator (* or &amp;) to either the variable type (left) or variable name (right),
  1247. or place it between the type and name. The spacing between the type and name will be preserved, if possible. This
  1248. option is effective for C/C++ files only.</p>
  1249. <div class="code">
  1250. <pre>char *foo1;</pre>
  1251. <p class="code">
  1252. becomes (with align-pointer=type):</p>
  1253. <pre>char* foo1;</pre>
  1254. </div>
  1255. <div class="code">
  1256. <pre>char* foo2;</pre>
  1257. <p class="code">
  1258. becomes (with align-pointer=middle):</p>
  1259. <pre>char * foo2;</pre>
  1260. </div>
  1261. <div class="code">
  1262. <pre>char& foo3;</pre>
  1263. <p class="code">
  1264. becomes (with align-pointer=name):</p>
  1265. <pre>char &amp;foo3;</pre>
  1266. </div>
  1267. <p>
  1268. &nbsp;</p>
  1269. <p id="_mode">
  1270. <code class="title">--mode=c</code><br />
  1271. <code class="title">--mode=cs</code><br />
  1272. <code class="title">--mode=java</code><br />
  1273. Indent a C/C++, C#, or Java file. The option is usually set from the file extension for each file. You can override
  1274. the setting with this entry. It will be used for all files regardless of the file extension. It allows the formatter
  1275. to identify language specific syntax such as C++ classes, templates, and keywords.</p>
  1276. <p>
  1277. &nbsp;</p>
  1278. <hr />
  1279. <!-- * * * * * * * * * * * * * Other Options * * * * * * * * * * * * * -->
  1280. <h3 id="_Other_Options">
  1281. Other Options</h3>
  1282. <p id="_suffix">
  1283. <code class="title">--suffix=<span class="option">####</span></code><br />
  1284. Append the suffix #### instead of '.orig' to original filename (e.g. <code>--suffix=<span class="option">.bak</span></code>).
  1285. If this is to be a file extension, the dot '.' must be included. Otherwise the suffix will be appended to the
  1286. current file extension.</p>
  1287. <p id="_suffix=none">
  1288. <code class="title">--suffix=none / -n</code><br />
  1289. Do not retain a backup of the original file. The original file is purged after it is formatted.</p>
  1290. <p id="_options">
  1291. <code class="title">--options=<span class="option">####</span></code><br />
  1292. Specify an options file #### to read and use. It must contain a file path for the file. This will allow the file
  1293. name to be changed from astylerc or .astylerc.&nbsp;</p>
  1294. <p id="_options=none">
  1295. <code class="title">--options=none</code><br />
  1296. Disable the default options file. Only the command-line parameters will be used.</p>
  1297. <p id="_recursive">
  1298. <code class="title">--recursive / -r / -R</code><br />
  1299. For each directory in the command line, process all subdirectories recursively. When using the recursive option
  1300. the file name statement should contain a wildcard. Linux users should place the filepath and name in double quotes
  1301. so the shell will not resolve the wildcards (e.g. "$HOME/src/*.cpp"). Windows users should place the filepath
  1302. and name in double quotes if the path or name contains spaces.</p>
  1303. <p id="_exclude">
  1304. <code class="title">--exclude=<span class="option">####</span></code><br />
  1305. Specify a file or sub directory #### to be excluded from processing.&nbsp;</p>
  1306. <p>
  1307. Excludes are matched from the end of the filepath. An exclude option of "templates" will exclude ALL directories
  1308. named "templates". An exclude option of "cpp/templates" will exclude ALL "cpp/templates" directories. You may
  1309. proceed backwards in the directory tree to exclude only the required directories.</p>
  1310. <p>
  1311. Specific files may be excluded in the same manner. An exclude option of "default.cpp" will exclude ALL files named
  1312. "default.cpp". An exclude option of "python/default.cpp" will exclude ALL files named "default.cpp" contained
  1313. in a "python" subdirectory. You may proceed backwards in the directory tree to exclude only the required files.</p>
  1314. <p>
  1315. Wildcards are NOT allowed. There may be more than one exclude statement. The filepath and name may be placed in
  1316. double quotes (e.g. &#8209;&#8209;exclude="foo&nbsp;bar.cpp").</p>
  1317. <p id="_errors-to-stdout">
  1318. <code class="title">--errors-to-stdout / -X</code><br />
  1319. Print errors to standard-output rather than to standard-error.<br />
  1320. This option should be helpful for systems/shells that do not have this option, such as in Windows95.</p>
  1321. <p id="_preserve-date">
  1322. <code class="title">--preserve-date / -Z</code><br />
  1323. Preserve the original file's date and time modified. The date and time modified will not be changed in the formatted
  1324. file. This option is not effective if redirection is used to rename the input file.</p>
  1325. <p id="_verbose">
  1326. <code class="title">--verbose / -v</code><br />
  1327. Verbose display mode. Display optional information, such as release number and statistical data.</p>
  1328. <p id="_formatted">
  1329. <code class="title">--formatted / -Q</code><br />
  1330. Formatted files display &nbsp;mode. Display only the files that have been formatted. Do not display files that
  1331. are unchanged.</p>
  1332. <p id="_quiet">
  1333. <code class="title">--quiet / -q</code><br />
  1334. Quiet display mode. Suppress all output except error messages.</p>
  1335. <p id="_lineend">
  1336. <code class="title">--lineend=windows&nbsp;/ -z1<br />
  1337. --lineend=linux &nbsp; / -z2<br />
  1338. --lineend=macold&nbsp;&nbsp;/ -z3</code><br />
  1339. Force use of the specified line end style. Valid options are windows (CRLF), linux (LF), and macold (CR). MacOld
  1340. 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
  1341. line ends will be determined automatically from the input file.</p>
  1342. <p id="_version">
  1343. <code class="title">--version / -V</code><br />
  1344. Print version number and quit. The short option must be by itself, it cannot be concatenated with other options.</p>
  1345. <p id="_help">
  1346. <code class="title">--help / -h / -?</code><br />
  1347. Print a help message and quit. The short option must be by itself, it cannot be concatenated with other options.</p>
  1348. <p>
  1349. &nbsp;</p>
  1350. <hr style="margin-left: -0.4in;" />
  1351. <center class="footer">
  1352. <table width="100%">
  1353. <col width="30%" />
  1354. <col width="40%" />
  1355. <col width="30%" />
  1356. <tr><td align="left"><a href="http://www.gnu.org/copyleft/lesser.html">
  1357. <img src="http://www.gnu.org/graphics/lgplv3-88x31.png" alt="[LGPLv3]" /></a> <a href="http://www.gnu.org/licenses/gpl.html">
  1358. <img src="http://www.gnu.org/graphics/gplv3-88x31.png" alt="[GPLv3]" /></a></td>
  1359. <td align="center" style="color: #0000A0; font-size: x-large; font-weight: bold;">ENJOY !!!</td>
  1360. <td align="right"><a href="http://sourceforge.net/projects/astyle">
  1361. <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=2319&type=15" width="150" height="40" alt="[SourceForge.net]" /></a>
  1362. </td>
  1363. </tr>
  1364. </table>
  1365. </center>
  1366. <p>
  1367. &nbsp;</p>
  1368. <p>
  1369. &nbsp;</p>
  1370. <!-- CUT HERE FOR INSERTION INTO SOURCEFORGE DOC MANAGER -->
  1371. </body>
  1372. </html>