1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452
|
<!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>
|