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 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en" 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="favicon.ico" rel="shortcut icon" type="image/x-icon" />
<link href="styles.css" rel="stylesheet" type="text/css" />
<!-- the following styles are additions to styles.css -->
<style type="text/css">
hr { margin-left: -0.4in; }
/* the following styles are for formatting code samples */
div.code { background: #D8D8FF; }
/* code */
p.code { margin-left: 0.3in; }
code { color: navy; }
code.title { font-size: larger; font-weight: bold; }
/* spans */
span.brace { color: red; }
span.comment { color: dimgray; font-style: italic; }
span.option { color: saddlebrown; font-weight: bold; }
</style>
</head>
<body>
<h1>Artistic Style 2.06</h1>
<h2>
A Free, Fast, and Small Automatic Formatter<br />
for C, C++, C++/CLI, Objective‑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="#_Quick_Start">Quick Start</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="#_Disable_Formatting">Disable Formatting</a></p>
<p class="contents1">
<a class="contents" href="#_Basic_Bracket_Styles">Basic Bracket Styles</a></p>
<p class="contents1">
<a class="contents" href="#_Bracket_Style_Options">Bracket Style Options</a></p>
<p class="contents2">
<a class="contents" href="#_default_bracket_style">default bracket style</a>
<a class="contents" href="#_style=allman">style=allman</a>
<a class="contents" href="#_style=java">style=java</a>
<a class="contents" href="#_style=kr">style=kr</a>
<a class="contents" href="#_style=stroustrup">style=stroustrup</a>
<a class="contents" href="#_style=whitesmith">style=whitesmith</a>
<a class="contents" href="#_style=vtk">style=vtk</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>
<a class="contents" href="#_style=google">style=google</a>
<a class="contents" href="#_style=mozilla">style=mozilla</a>
<a class="contents" href="#_style=pico">style=pico</a>
<a class="contents" href="#_style=lisp">style=lisp</a> </p>
<p class="contents1">
<a class="contents" href="#_Tab_Options">Tab 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="#_indent=force-tab-x">--indent=force‑tab‑x</a> </p>
<p class="contents1">
<a class="contents" href="#_Bracket_Modify_Options">Bracket Modify Options</a></p>
<p class="contents2">
<a class="contents" href="#_attach_namespaces">attach‑namespaces</a>
<a class="contents" href="#_attach_classes">attach‑classes</a>
<a class="contents" href="#_attach_inlines">attach‑inlines</a>
<a class="contents" href="#_attach-extern-c">attach‑extern‑c</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-modifiers">indent‑modifiers</a>
<a class="contents" href="#_indent-switches">indent‑switches</a>
<a class="contents" href="#_indent-cases">indent‑cases</a>
<a class="contents" href="#_indent-namespaces">indent‑namespaces</a>
<a class="contents" href="#_indent-continuation">indent‑continuation</a>
<a class="contents" href="#_indent-labels">indent‑labels</a>
<a class="contents" href="#_indent-preproc-block">indent‑preproc‑block</a>
<a class="contents" href="#_indent-preproc-define">indent‑preproc‑define</a>
<a class="contents" href="#_indent-preproc-cond">indent‑preproc‑cond</a>
<a class="contents" href="#_indent-col1-comments">indent‑col1‑comments</a>
<a class="contents" href="#_min-conditional-indent">min‑conditional‑indent</a>
<a class="contents" href="#_max-instatement-indent">max‑instatement‑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-comma">pad‑comma</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-first-paren-out">pad‑first‑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>
<a class="contents" href="#_align-pointer">align‑pointer</a>
<a class="contents" href="#_align-reference">align‑reference</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="#_break-one-line-headers">break‑one‑line‑headers</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="#_remove-brackets">remove‑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="#_close-templates">close‑templates</a>
<a class="contents" href="#_remove-comment-prefix">remove‑comment‑prefix</a>
<a class="contents" href="#_max-code-length">max‑code‑length</a>
<a class="contents" href="#_max-code-length">break‑after‑logical</a>
<a class="contents" href="#_mode">mode</a> </p>
<p class="contents1">
<a class="contents" href="#_Objective_C_Options">Objective‑C Options</a></p>
<p class="contents2">
<a class="contents" href="#_pad-method-prefix">pad‑method‑prefix</a>
<a class="contents" href="#_unpad-method-prefix">unpad‑method‑prefix</a>
<a class="contents" href="#_pad-return-type">pad‑return‑type</a>
<a class="contents" href="#_unpad-return-type">unpad‑return‑type</a>
<a class="contents" href="#_pad-param-type">pad‑param‑type</a>
<a class="contents" href="#_unpad-param-type">unpad‑param‑type</a>
<a class="contents" href="#_align-method-colon">align‑method‑colon</a>
<a class="contents" href="#_pad-method-colon">pad‑method‑colon</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="#_recursive">recursive</a>
<a class="contents" href="#_dry-run">dry-run</a>
<a class="contents" href="#_exclude">exclude</a>
<a class="contents" href="#_ignore-exclude-errors">ignore‑exclude‑errors</a>
<a class="contents" href="#_ignore-exclude-errors-x">ignore‑exclude‑errors‑x</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> </p>
<p class="contents1">
<a class="contents" href="#_Command_Line_Only">Command Line Only</a></p>
<p class="contents2">
<a class="contents" href="#_options=">options</a>
<a class="contents" href="#_options=none">options=none</a>
<a class="contents" href="#_ascii">ascii</a>
<a class="contents" href="#_version">version</a>
<a class="contents" href="#_help">help</a>
<a class="contents" href="#_html">html</a>
<a class="contents" href="#_html=">html=</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 type file (C, C++, C++/CLI, or Objective-C). If you are
using a non-standard file extension for Java or C#, use one of the --mode= 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 file name contains wildcards. For Windows use double quotes around paths whose
file name contains spaces. The <a href="#_recursive">recursive</a> option in the
<a href="#_Other_Options">Other Options</a> 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 <strong>.orig</strong> appended to the original file name. (This can be set to
a different string by the option --suffix=, or suppressed altogether by the options -n
or --suffix=none). Thus, after indenting <em>SourceFile.cpp</em> the indented file will
be named <em>SourceFile.cpp</em>, while the original pre-indented file will be renamed to
<em>SourceFile.cpp.orig</em>.</p>
<h4>Internationalization</h4>
<p>
Artistic Style has been internationalized to process files and directories in any language.</p>
<p>
It has also been translated into several languages. The translation to use is determined by the User Locale
for Windows and the LANG environment variable for other systems. The translation will be done automatically from
these settings. If no translation is available it will default to English. There is an "ascii" option to use English
instead of the system language.</p>
<p>
The source code for the translations is at the end of ASLocalizer.cpp in the form of an English‑Translation
pair. If you make corrections to a translation, send the source as a bug report and it will be included in the
next release.</p>
<p>
To add a new language, add a new translation class to ASLocalizer.h. Add the English‑Translation pair to
the constructor in ASLocalizer.cpp. Update the WinLangCode array and add the language code to the function setTranslationClass().
The ASLocalizer.cpp program contains comments that give web pages for obtaining the LCIDs and language codes.
Send the source code as a bug report and it will be included in the next release.</p>
<h4>Other Considerations</h4>
<p>
The names of special characters used in programming vary by region. The terminology used by Artistic Style,
followed by other common names, is<strong>:</strong></p>
<blockquote>
brackets { } ‑ also called braces, curly brackets, or curly braces.<br />
parens ( ) ‑ also called parentheses, brackets, round brackets, circle brackets, or soft brackets.<br />
block parens [ ] ‑ also called brackets, square brackets, closed brackets, or hard brackets.<br />
angle brackets < > ‑ also called brackets, pointy brackets, triangular brackets, diamond brackets, tuples,
or chevrons.
</blockquote>
<p>
Visual Studio, and possibly other development environments, has an Edit option "Align Assignments" that will align
assignment operators across multiple lines. There is also an extension named "Code alignment" that will align
the code on other items as well. Formatting with these options and extensions can be used with Artistic Style.
The space padding will be maintained and the alignment will be preserved. </p>
<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>
Unicode files encoded as UTF‑16, both big and little endian, will be formatted. The files must begin with
a byte order mark (BOM) to be recognized. Files encoded as UTF‑32 will be rejected. Some compilers do not
support these encodings. These files can be converted to UTF‑8 encoding with the program "iconv". There
are Linux and Windows versions available (the Windows version does not seem to work for all encodings). 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. Then 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
<a href="#_exclude">exclude=####</a> option described in the <a href="#_Other_Options">Other Options</a>
section.</p>
<p>
</p>
<hr />
<!-- * * * * * * * * * * * * * * Quick Start * * * * * * * * * * * * * * -->
<h3 id="_Quick_Start">Quick Start</h3>
<p>
If you have never used Artistic Style there are a
several of ways to start.</p>
<p>
One is to run it with no options at all. This will use the <a href="#_default_bracket_style">default bracket
style</a>, 4 spaces per indent, and no formatting changes. This will break the brackets for one
line blocks and will break one line statements. To change this, use the option <a href="#_keep-one-line-blocks">keep-one-line-blocks</a>
and/or <a href="#_keep-one-line-statements">keep-one-line-statements</a> described in the
<a href="#_Formatting_Options">Formatting Options</a> section.</p>
<p>
Another way is to use one of the bracket styles described in the <a href="#_Bracket_Style_Options">Bracket Style
Options</a> section. Select one with a bracket formatting style you like. If no indentation option is set,
the default option of 4 spaces will be used. These options also break one line blocks and one line statements
as described above.</p>
<p>
A third option is to use an options file from the "file" folder. If there is a coding style you want
to duplicate, input the appropriate <a href="#_Options_File">options file</a>. Use the option
<a href="#_options=">options=####</a> to specify the file to use. It must contain a path for the file, including
the file name. </p>
<p>
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.</p>
<div class="code">
<p class="code">
Command line format:</p>
<pre>astyle [OPTIONS] <em>SourceFile1 SourceFile2 SourceFile3 [ . . . ]</em></pre>
</div>
<p>
The block parens [ ] indicate that more than one option or more than one file name can be entered. They are NOT
actually included in the command. For the options format refer to the following Options section.</p>
<div class="code">
<p class="code">
Example to format a single file:</p>
<pre>astyle --style=allman /home/user/project/foo.cpp
</pre>
<p class="code">
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>
The < and > characters may be used to redirect the files into standard input (stdin) and out of standard output
(stdout) - 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. On Windows the output will always have
Windows line ends.</p>
<div class="code">
<p class="code">
Example of redirection option to format a single file and change the name:</p>
<pre>astyle --style=allman < <em>OriginalSourceFile</em> > <em>BeautifiedSourceFile</em>
</pre>
</div>
<div class="code">
<p class="code">
The redirection option may be used to display the formatted file without updating:</p>
<pre>astyle --style=allman < <em>OriginalSourceFile</em> | less
</pre>
</div>
<p>
</p>
<hr />
<!-- * * * * * * * * * * * * * * * Options * * * * * * * * * * * * * * * -->
<h3 id="_Options">Options</h3>
<p>
Not specifying any options will result in the <a href="#_default_bracket_style">default bracket style</a>,
4 spaces per indent, 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: '--style=allman --indent=spaces=4')</p>
<h4>Short Options</h4>
<p>
These options start with a single '<strong>-</strong>', and may be concatenated together.<br />
(Example: '-bps4' is the same as writing '-b -p -s4'.)</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>
--style=allman <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>
-M60Ucv</pre>
</div>
<p>
</p>
<hr />
<!-- * * * * * * * * * * * * * Disable Formatting * * * * * * * * * * * * * -->
<h3 id="_Disable_Formatting">Disable Formatting</h3>
<p>
Formatting and indenting can be disabled with comment tags inserted in the source code.</p>
<h4>Disable Block</h4>
<p>
Blocks of code can be disabled using "off" and "on" tags. The tags are included in the source
file as comments. The comment may be a C comment (/* ... */) or a C++ line comment (//). The tag must be included
in a single line comment. If the comment exceeds one line the indent tag will be ignored. Additional information
can be included with the tag.</p>
<p>
The beginning tag is "*INDENT-OFF*" and the ending tag is "*INDENT-ON*".
They may be used anywhere in the program with the condition that parsing is partially disabled between the
tags. Disabling partial statements may result in incorrect formatting after the ending tag. If this happens expand
the tags to include additional code.</p>
<div class="code">
<p class="code">
The following retains the format of a preprocessor define:</p>
<pre><span class="comment">// *INDENT-OFF*</span>
#define FOO_DECLARE_int32_(name) \
FOO_API_ extern ::Int32 FOO_FLAG(name)
<span class="comment">// *INDENT-ON*</span></pre>
</div>
<h4>Disable Line</h4>
<p>
Artistic Style cannot always determine the usage of symbols with more than one meaning. For example an asterisk
(*) can be multiplication, a pointer, or a pointer dereference. The "&" and "&&"
symbols are a similar
problem.</p>
<p>
If a symbol is being padded incorrectly, padding it manually may fix the problem. If it is still being
padded incorrectly, then disabling the formatting may be necessary. To avoid having to use the "disable block"
tags above, a single line disable is available.</p>
<p>
A line-end comment tag "*NOPAD* will disable the "pad-oper", "align-pointer", and "align-reference"
options. Parsing does NOT stop and all other formatting will be applied to the line. The tag applies to the
one line only.</p>
<div class="code">
<p class="code">
The following prevents the operator padding from changing:</p>
<pre>size_t foo = (unsigned int) -1; <span class="comment">// *NOPAD*</span></pre>
</div>
<p>
</p>
<hr />
<!-- * * * * * * * * * * * * Basic Bracket Styles * * * * * * * * * * * * -->
<h3 id="_Basic_Bracket_Styles">Basic Bracket Styles</h3>
<p>
There are three basic bracket styles.<br />
Attached – The brackets are attached to the end of
the last line of the previous block. (Java).<br />
Broken – The brackets are broken from the previous
block. (Allman).<br />
Linux – The brackets are attached except for the opening bracket of a function, class, or namespace (K&R,
Linux).</p>
<p>
Other bracket styles are variations of these. Some will use variations on the placement of class, namespace,
or other brackets. (Stroustrup, Google, One True Brace, Lisp). Others will indent the brackets (Whitesmith, VTK,
Banner, GNU). Still others will use run-in brackets where the following statement is on the same line as the bracket
(Horstmann, Pico).</p>
<p>
There are technical arguments for selecting one style over another. But the usual reason comes down to
personal preference. Some like broken brackets with vertical whitespace that makes the code easy to read.
Others like attached brackets with code that is more compact. Sometimes programmers just want a change. It is
easier to select a preference if you can see an entire file formatted in a certain bracket style. With Artistic
Style you can easily modify source code to suit your
preference.</p>
<p>
</p>
<hr />
<!-- * * * * * * * * * * * * Bracket Style Options * * * * * * * * * * * * -->
<h3 id="_Bracket_Style_Options">Bracket Style Options</h3>
<p>
Bracket Style options define the bracket style to use. All options default to 4 spaces per indent, indented with
spaces. By default, none of the styles indent namespaces. Other indentations are indicated in the individual style
description. All options will break the brackets for one line blocks and will break one line statements. To change
this, use the option <a href="#_keep-one-line-blocks">keep-one-line-blocks</a> and/or <a href="#_keep-one-line-statements">
keep-one-line-statements</a> described in the <a href="#_Formatting_Options">Formatting Options</a>
section.</p>
<p>
</p>
<p id="_default_bracket_style">
<code class="title">default bracket style</code><br />
If no bracket style is requested, the default bracket style will be used. The opening brackets are not changed
and the closing brackets will be broken from the preceding line. There are a few exceptions to this.</p>
<p>
</p>
<p id="_style=allman">
<code class="title">--style=allman / --style=bsd / --style=break / -A1</code><br />
Allman style 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 / --style=attach / -A2</code><br />
Java style 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=kr">
<code class="title">--style=kr / --style=k&r / --style=k/r / -A3</code><br />
Kernighan & Ritchie style uses linux brackets. Opening brackets are broken from namespaces, classes, and function
definitions. The brackets are attached to everything else, including arrays, structs, enums, and 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 uses linux brackets. Opening brackets are broken from function definitions only.
The brackets are attached to everything else, including namespaces, classes, arrays, structs, enums,
and statements within a function. This style frequently is used with headers broken from closing brackets
(break-closing-brackets) and an indent of 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 uses broken, indented brackets. Switch blocks and class blocks are indented to prevent a 'hanging
indent' with the following case 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=vtk">
<code class="title">--style=vtk / -A15</code><br />
VTK (Visualization Toolkit) style uses broken, indented brackets, except for the opening bracket. Switch blocks
are indented to prevent a 'hanging indent' with following case statements. </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 uses attached, indented brackets. Switch blocks and class blocks are indented to prevent a 'hanging
indent' with following case 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 uses broken brackets and indented blocks. Extra indentation is added to blocks <strong>within a
function</strong> only. Other brackets and blocks are broken, but NOT indented. This style frequently is
used with an indent of 2 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=linux">
<code class="title">--style=linux / --style=knf / -A8</code><br />
Linux style uses linux brackets. Opening brackets are broken from namespace, class, and function definitions.
The brackets are attached to everything else, including arrays, structs, enums, and statements within a function.
The <strong>minimum conditional indent</strong> is one-half indent. If you want a different minimum conditional
indent, use the K&R style instead. This style works best with a large indent. It frequently is used with
an indent of 8 spaces.</p>
<p>
Also known as Kernel Normal Form (KNF) style, this is the style used in the Linux
BSD 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 uses broken brackets and run-in statements. Switches are indented to allow a run-in to the opening
switch block. This style frequently is used with an indent of 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" uses linux brackets and adds brackets to unbracketed one line conditional statements. Opening
brackets are broken from namespaces, classes, and function definitions. The brackets are attached to everything
else, including arrays, structs, enums, and statements within a function. </p>
<p>
In the following example, brackets have been added to the "return 0;" 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>
<p id="_style=google">
<code class="title">--style=google / -A14</code><br />
Google style uses attached brackets and indented class access modifiers. See the indent-modifiers
option for an example of the indented modifiers format. This is not actually a unique bracket style, but
is Java style with a non-bracket variation. This style frequently is used with an indent of 2 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=mozilla">
<code class="title">--style=mozilla / -A16</code><br />
Mozilla style uses linux brackets. Opening brackets are broken from classes, structs, enums, and function
definitions. The brackets are attached to everything else, including namespaces, arrays, and statements
within a function. This style frequently is used with an indent of 2 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=pico">
<code class="title">--style=pico / -A11</code><br />
Pico style uses broken brackets and run-in statements with attached closing brackets. The closing bracket is attached
to the last line in the block. Switches are indented to allow a run-in to the opening switch block. The style
implies keep-one-line-blocks and keep-one-line-statements. If add-brackets is used they will be added as one-line
brackets. This style frequently is used with an indent of 2 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=lisp">
<code class="title">--style=lisp / --style=python / -A12</code><br />
Lisp style uses attached opening and closing brackets. The closing bracket is attached to the last line in the
block. The style implies keep-one-line-statements, but NOT keep-one-line-blocks. This style does not support one-line
brackets. If add-one-line-brackets is used they will be added as multiple-line 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>
<hr />
<!-- * * * * * * * * * * * * * * * Tab Options * * * * * * * * * * * * * * * -->
<h3 id="_Tab_Options">Tab Options</h3>
<p>
The following examples show whitespace characters. A space is indicated with a <strong>.</strong> (dot), a tab
is indicated by a > (greater than).</p>
<p id="_default_indent">
<code class="title">default indent</code><br />
If no indentation option is set, the default option of 4 spaces will be used (e.g. -s<span class="option">4</span>
--indent=spaces=<span class="option">4</span>).</p>
<div class="code">
<p class="code">
with default values:</p>
<pre>void Foo() <span class="brace">{</span>
....if (isBar1
............&& isBar2) <span class="comment">// indent of this line can be changed with min-conditional-indent</span>
........bar();
<span class="brace">}</span>
</pre>
</div>
<p>
</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 # <strong>spaces</strong> per indent (e.g. -s<span class="option">3</span> --indent=spaces=<span
class="option">3</span>). # must be between 2 and 20. Not specifying # will result in a default of
4 spaces per indent.</p>
<div class="code">
<p class="code">
with indent=spaces=3</p>
<pre>void Foo() <span class="brace">{</span>
...if (isBar1
.........&& isBar2) <span class="comment">// indent of this line can be changed with min-conditional-indent</span>
......bar();
<span class="brace">}</span>
</pre>
</div>
<p>
</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 <strong>tabs for indentation, and spaces for continuation line alignment</strong>. This ensures that
the code is displayed correctly regardless of the viewer’s tab size. Treat each indent as # spaces
(e.g. -t<span class="option">6</span> / --indent=tab=<span class="option">6</span>).
# must be between 2 and 20. If no # is set, treats indents as 4 spaces.</p>
<div class="code">
<p class="code">
with indent=tab:</p>
<pre>void Foo() <span class="brace">{</span>
> if (isBar1
> ........&& isBar2) <span class="comment">// indent of this line can be changed with min-conditional-indent</span>
> > bar();
<span class="brace">}</span>
</pre>
<p class="code">
with style=linux, indent=tab=8:</p>
<pre>void Foo()
<span class="brace">{</span>
> if (isBar1
> ....&& isBar2) <span class="comment">// indent of this line can NOT be changed with style=linux</span>
> > bar();
<span class="brace">}</span>
</pre>
</div>
<p>
</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 <strong>all tab</strong> characters, if possible. If a continuation line is not an even number of
tabs, spaces will be added at the end. Treat each tab as # spaces (e.g. -T<span class="option">6</span>
/ --indent=<span lang="en-us">force-</span>tab=<span class="option">6</span>). # must be between
2 and 20. If no # is set, treats tabs as 4 spaces.</p>
<div class="code">
<p class="code">
with indent=force-tab:</p>
<pre>void Foo() <span class="brace">{</span>
> if (isBar1
> > > && isBar2) <span class="comment">// indent of this line can be changed with min-conditional-indent</span>
> > bar();
<span class="brace">}</span>
</pre>
</div>
<p>
</p>
<p id="_indent=force-tab-x">
<code class="title">--indent=force-tab-x / --indent=force-tab-x=<span class="option">#</span> / -xT / -xT<span
class="option">#</span>
</code><br />
This force-tab option allows the tab length to be set to a length that is different than the indent length. This
may cause the indentation to be <strong>a mix of both tabs and spaces.</strong> Tabs will be used to indent, if
possible. If a tab indent cannot be used, spaces will be used instead.</p>
<p>
This option sets the <strong>tab length.</strong> Treat each tab as # spaces (e.g. -xT<span class="option">6</span>
/ --indent=<span lang="en-us">force-</span>tab-x=<span class="option">6</span>. # must be between
2 and 20. If no # is set, treats tabs as 8 spaces. To change the <strong>indent length</strong> from the default
of 4 spaces the option "indent=force-tab" must also be used.</p>
<div class="code">
<p class="code">
with indent=force-tab-x (default tab length of 8 and default indent length of 4):</p>
<pre>void Foo() <span class="brace">{</span>
....if (isBar1
> ....&& isBar2) <span class="comment">// indent of this line can be changed with min-conditional-indent</span>
> bar();
<span class="brace">}</span>
</pre>
</div>
<p>
</p>
<hr />
<!-- * * * * * * * * * * * * Bracket Modify Options * * * * * * * * * * * * -->
<h3 id="_Bracket_Modify_Options">Bracket Modify Options</h3>
<p id="_attach_namespaces">
<code class="title">--attach-namespaces / -xn</code><br />
Attach brackets to a namespace statement. This is done regardless of the bracket style being used.
It will also attach brackets to CORBA IDL module statements.</p>
<div class="code">
<p class="code">
the bracket is always attached to a namespace statement:</p>
<pre>namespace FooName <span class="brace">{</span>
...
<span class="brace">}</span>
</pre>
</div>
<p>
</p>
<p id="_attach_classes">
<code class="title">--attach-classes / -xc</code><br />
Attach brackets to a class statement. This is done regardless of the bracket style being used.</p>
<div class="code">
<p class="code">
the bracket is always attached to a class statement:</p>
<pre>class FooClass <span class="brace">{</span>
...
<span class="brace">}</span>;
</pre>
</div>
<p>
</p>
<p id="_attach_inlines">
<code class="title">--attach-inlines / -xl</code><br />
Attach brackets to class and struct inline function definitions. This is not done for run-in type brackets
(Horstmann and Pico styles). This option is effective for C++ files only.</p>
<div class="code">
<p class="code">
all brackets are always attached to class and struct inline function definitions:</p>
<pre>class FooClass
<span class="brace">{</span>
void Foo() <span class="brace">{</span>
...
<span class="brace"> }</span>
<span class="brace">}</span>;
</pre>
</div>
<p>
</p>
<p id="_attach-extern-c">
<code class="title">--attach-extern-c / -xk</code><br />
Attach brackets to a bracketed extern "C" statement. This is done regardless of the bracket style being used.
This option is effective for C++ files only.</p>
<p>
An extern "C" statement that is part of a function definition is formatted according to the requested bracket
style. Bracketed extern "C" statements are unaffected by the bracket style and this option is the only way to
change them.</p>
<div class="code">
<p class="code">
this option attaches brackets to a bracketed extern "C" statement:</p>
<pre>#ifdef __cplusplus
extern "C" <span class="brace">{</span>
#endif
</pre>
<p class="code">
but function definitions are formatted according to the requested bracket style:</p>
<pre>extern "C" EXPORT void STDCALL Foo()
<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 'class' and 'struct' blocks so that the entire block is indented. The struct
blocks are indented only if an access modifier, 'public:', 'protected:' or 'private:',
is declared somewhere in the struct. 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-modifiers">
<code class="title">--indent-modifiers / -xG</code><br />
Indent 'class ' and 'struct' access modifiers, 'public:', 'protected:'
and 'private:', one half indent. The rest of the class is not indented. This option is effective
for C++ files only. If used with indent‑classes this option will be ignored.</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 'switch' blocks so that the 'case X:' statements are indented in the switch 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-namespaces">
<code class="title">--indent-namespaces / -N</code><br />
Add extra indentation to namespace blocks. This option has no effect on Java files. It
will also indent CORBA IDL module statements.</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-continuation">
<code class="title">--indent-continuation=<span class="option">#</span> / -xt<span class="option">#</span></code><br />
Set the continuation indent for a line that ends with an opening paren '<code>(</code>' or an assignment
'<code>=</code>'. This includes function definitions and declarations. The value for <span class="option">#</span>
indicates a <strong>number of indents</strong>. The valid values are the integer
values from <strong>0 thru 4</strong>: The default value is <strong>1</strong>, one indent.</p>
<div class="code">
<pre>isLongVariable =
foo1 ||
foo2;
isLongFunction(
bar1,
bar2);
</pre>
<p class="code">
becomes (with indent-continuation=3):</p>
<pre>isLongVariable =
foo1 ||
foo2;
isLongFunction(
bar1,
bar2);
</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-preproc-block">
<code class="title">--indent-preproc-block / -xW</code><br />
Indent preprocessor blocks at bracket level zero and immediately within a namespace. There are restrictions on
what will be indented. Blocks within methods, classes, arrays, etc., will not be indented. Blocks containing brackets
or multi-line define statements will not be indented. Without this option the preprocessor block is not
indented.</p>
<div class="code">
<pre>#ifdef _WIN32
#include <windows.h>
#ifndef NO_EXPORT
#define EXPORT
#endif
#endif
</pre>
<p class="code">
becomes:</p>
<pre>#ifdef _WIN32
#include <windows.h>
#ifndef NO_EXPORT
#define EXPORT
#endif
#endif
</pre>
</div>
<p>
</p>
<p id="_indent-preproc-define">
<code class="title">--indent-preproc-define / -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-preproc-cond">
<code class="title">--indent-preproc-cond / -xw</code><br />
Indent preprocessor conditional statements to the same level as the source code.</p>
<div class="code">
<pre> isFoo = true;
#ifdef UNICODE
text = wideBuff;
#else
text = buff;
#endif</pre>
<p class="code">
becomes:</p>
<pre> isFoo = true;
#ifdef UNICODE
text = wideBuff;
#else
text = buff;
#endif
</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
assumed to be commented‑out code and 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>
<span class="comment">// comment</span>
if (isFoo)
bar();
<span class="brace">}</span>
</pre>
<p class="code">
becomes:</p>
<pre>void Foo()\n"
<span class="brace">{</span>
<span class="comment">// comment</span>
if (isFoo)
bar();
<span class="brace">}</span>
</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>
<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 not be less than <strong>40</strong> nor
greater than <strong>120</strong>. If no value is set, the default value of <strong>40</strong> will be
used. 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>
<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. 'if', 'for', 'while'...).</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. 'if', 'for', 'while'...). Treat
closing header blocks (e.g. 'else', 'catch') 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. This will also pad commas. 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-comma">
<code class="title">--pad-comma / -xg </code><br />
Insert space padding after commas. This is not needed if pad-oper is used. 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 (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">
<code class="title">--pad-paren / -P </code>
<br />
Insert space padding around parens 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+2), b))
bar(a, b);
</pre>
<p class="code">
becomes:</p>
<pre>if ( isFoo ( ( a+2 ), 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 parens on the <strong>outside</strong> only. Parens that are empty will
not be padded. Any end of line comments will remain in the original column, if possible. This can be used with
unpad-paren below to remove unwanted spaces.</p>
<div class="code">
<pre>if (isFoo((a+2), b))
bar(a, b);
</pre>
<p class="code">
becomes:</p>
<pre>if (isFoo ( (a+2), b) )
bar (a, b);
</pre>
</div>
<p>
</p>
<p id="_pad-first-paren-out">
<code class="title">--pad-first-paren-out / -xd </code>
<br />
Insert space padding around the <strong>first</strong> paren in a series on the <strong>outside</strong>
only. Parens that are empty will not be padded. Any end of line comments will remain in the original column,
if possible. This can be used with unpad-paren below to remove unwanted spaces. If used with pad‑paren or
pad‑paren‑out, this option will be ignored. If used with pad‑paren‑in, the result will
be the same as pad‑paren.</p>
<div class="code">
<pre>if (isFoo((a+2), b))
bar(a, b);
</pre>
<p class="code">
becomes:</p>
<pre>if (isFoo ((a+2), 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 paren on the <strong>inside</strong> only. Any end of line comments will remain
in the original column, if possible. This can be used with unpad-paren below to remove unwanted spaces.</p>
<div class="code">
<pre>if (isFoo((a+2), b))
bar(a, b);
</pre>
<p class="code">
becomes:</p>
<pre>if ( isFoo( ( a+2 ), b ) )
bar( a, b );
</pre>
</div>
<p>
</p>
<p id="_pad-header">
<code class="title">--pad-header / -H </code>
<br />
Insert space padding between a header (e.g. 'if', 'for', 'while'...)
and the following paren. Any end of line comments will remain in the original column, if possible. This can
be used with unpad-paren to remove unwanted spaces.</p>
<div class="code">
<pre>if(isFoo((a+2), b))
bar(a, b);</pre>
<p class="code">
becomes:</p>
<pre>if (isFoo((a+2), 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 parens 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
pad‑paren, pad‑paren‑out, pad‑paren‑in,
and pad‑header 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 unpad-paren to remove the outside padding, and pad‑paren‑in to
retain the inside padding. Using only pad‑paren‑in> would not remove the outside
padding.</p>
<div class="code">
<pre>if ( isFoo( ( a+2 ), b ) )
bar ( a, b );
</pre>
<p class="code">
becomes (with no padding option requested):</p>
<pre>if(isFoo((a+2), b))
bar(a, b);
</pre>
</div>
<p>
</p>
<p id="_delete-empty-lines">
<code class="title">--delete-empty-lines / -xe</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>
<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 (middle). The spacing between the type and name will be preserved, if possible.
This option is for C/C++, C++/CLI, and C# files. To format references separately, use the following align-reference
option.</p>
<div class="code">
<pre>char* foo1;
char & foo2;
String ^s1;</pre>
<p class="code">
becomes (with align-pointer=type):</p>
<pre>char* foo1;
char& foo2;
String^ s1;</pre>
</div>
<div class="code">
<pre>char* foo1;
char & foo2;
String ^s1;</pre>
<p class="code">
becomes (with align-pointer=middle):</p>
<pre>char * foo1;
char & foo2;
String ^ s1;</pre>
</div>
<div class="code">
<pre>char* foo1;
char & foo2;
String ^s1;</pre>
<p class="code">
becomes (with align-pointer=name):</p>
<pre>char *foo1;
char &foo2;
String ^s1;</pre>
</div>
<p>
</p>
<p id="_align-reference">
<code class="title">--align-reference=none / -W0<br />
--align-reference=type / -W1<br />
--align-reference=middle / -W2<br />
--align-reference=name / -W3
</code><br />
This option will align references separate from pointers. Pointers are not changed by this option. If pointers
and references are to be aligned the same, use the previous align-pointer option. The option align-reference=none
will not change the reference alignment. The other options are the same as for align-pointer. This option is for
C/C++, C++/CLI, and C# files.</p>
<div class="code">
<pre>char &foo1;</pre>
<p class="code">
becomes (with align-reference=type):</p>
<pre>char& foo1;</pre>
</div>
<div class="code">
<pre>char& foo2;</pre>
<p class="code">
becomes (with align-reference=middle):</p>
<pre>char & foo2;</pre>
</div>
<div class="code">
<pre>char& foo3;</pre>
<p class="code">
becomes (with align-reference=name):</p>
<pre>char &foo3;</pre>
</div>
<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 --style=java, --style=kr, --style=stroustrup, --style=linux, or --style=1tbs, this breaks closing
headers (e.g. 'else', 'catch', ...) from their immediately preceding closing brackets. Closing header brackets
are always broken with the other styles.</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>
else
if (isFoo2()) <span class="brace">{</span>
bar2();
<span class="brace">}</span>
</pre>
</div>
<p>
</p>
<p id="_break-one-line-headers">
<code class="title">--break-one-line-headers / -xb </code>
<br />
</p>
<p>
Break one line headers (e.g. 'if', 'while', 'else', ...) from a statement residing
on the same line. If the statement is enclosed in brackets, the brackets will be formatted according to the requested
bracket style. </p>
<p>
A multi-statement line will NOT be broken if keep-one-line-statements is requested. One line blocks
will NOT be broken if keep-one-line-blocks is requested and the header is enclosed in the block. </p>
<div class="code">
<pre>void Foo(bool isFoo)
<span class="brace">{</span>
if (isFoo1) bar1();
if (isFoo2) <span class="brace">{</span> bar2(); <span class="brace">}</span>
<span class="brace">}</span>
</pre>
<p class="code">
becomes:</p>
<pre>void Foo(bool isFoo)
<span class="brace">{</span>
if (isFoo1)
bar1();
if (isFoo2) <span class="brace">{</span>
bar2();
<span class="brace">}</span>
<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. 'if', 'for', 'while'...). The statement must
be on a single line. The brackets will be added according to the requested bracket style. If no style is requested
the brackets will be attached. </p>
<p>
Brackets will NOT be added to a multi-statement line if keep-one-line-statements is requested. Brackets will
NOT be added to a one line block if keep-one-line-blocks is requested. 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. 'if', 'for',
'while'...). 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="_remove-brackets">
<code class="title">--remove-brackets / -xj</code><br />
Remove brackets from conditional statements (e.g. 'if', 'for', 'while'...).
The statement must be a single statement on a single line. If --add-brackets or --add-one-line-brackets is also
used the result will be to add brackets. Brackets will not be removed from "One True Brace Style",
--style=1tbs.</p>
<div class="code">
<pre>if (isFoo)
<span class="brace">{</span>
isFoo = false;
<span class="brace">}</span></pre>
<p class="code">
becomes:</p>
<pre>if (isFoo)
isFoo = false;
</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 within quotes.</p>
<p>
</p>
<p id="_close-templates">
<code class="title">--close-templates / -xy</code><br />
Closes whitespace between the ending angle brackets of template definitions. Closing the ending angle brackets
is now allowed by the C++11 standard. Be sure your compiler supports this before making the changes.</p>
<div class="code">
<pre>Stack< int, List< int > > stack1;</pre>
<p class="code">
becomes:</p>
<pre>Stack< int, List< int >> stack1;</pre>
</div>
<p>
</p>
<p id="_remove-comment-prefix">
<code class="title">--remove-comment-prefix / -xp</code><br />
Remove the preceding '*' in a multi-line comment that begins a line. A trailing '*', if present, is also removed.
Text that is less than one indent is indented to one indent. Text greater than one indent is not changed. Multi-line
comments that begin a line, but without the preceding '*', are indented to one indent for consistency. This can
slightly modify the indentation of commented out blocks of code. Lines containing all '*' are left unchanged.
Extra spacing is removed from the comment close '*/'.</p>
<div class="code">
<pre><em>/*
* comment line 1
* comment line 2
*/</em></pre>
<p class="code">
becomes:</p>
<pre><em>/*
comment line 1
comment line 2
*/</em></pre>
</div>
<p>
</p>
<p id="_max-code-length">
<code class="title">--max-code-length=<span class="option">#</span> / -xC<span class="option">#</span>
<br />
--break-after-logical / -xL</code><br />
The option max‑code‑length will break a line if the code exceeds <span class="option">#</span>
characters. The valid values are 50 thru 200. Lines without logical conditionals will break on a logical conditional
(||, &&, ...), comma, paren, semicolon, or space.</p>
<p>
Some code will not be broken, such as comments, quotes, and arrays. If used with keep‑one‑line‑blocks
or add-one-line-brackets the blocks will NOT be broken. If used with keep‑one‑line‑statements
the statements will be broken at a semicolon if the line goes over the maximum length. If there is no available
break point within the max code length, the line will be broken at the first available break point after the max
code length.</p>
<p>
By default logical conditionals will be placed first in the new line. The option break‑after‑logical
will cause the logical conditionals to be placed last on the previous line. This option has no effect without
max‑code‑length.</p>
<div class="code">
<pre>if (thisVariable1 == thatVariable1 || thisVariable2 == thatVariable2 || thisVariable3 == thatVariable3)
bar();</pre>
<p class="code">
becomes:</p>
<pre>if (thisVariable1 == thatVariable1
|| thisVariable2 == thatVariable2
|| thisVariable3 == thatVariable3)
bar();</pre>
<p class="code">
becomes (with break‑after‑logical):</p>
<pre>if (thisVariable1 == thatVariable1 ||
thisVariable2 == thatVariable2 ||
thisVariable3 == thatVariable3)
bar();</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 type, C#, or Java file. C type files are C, C++, C++/CLI, and Objective-C. 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 />
<!-- * * * * * * * * * * * * * Objective-C Options * * * * * * * * * * * * * -->
<h3 id="_Objective_C_Options">Objective‑C Options</h3>
<p>
These options are effective for Objective‑C files only. The paren padding options will still apply to the
Objective-C method prefix and return type unless overridden by the following options.</p>
<p>
Because of the longer indents sometimes needed for Objective‑C, the option "max-instatement-indent" may
need to be increased. If you are not getting the paren and block paren alignment you want try increasing this
value. The option is described in the "Indentation Options" section.</p>
<p id="_pad-method-prefix">
<code class="title">--pad-method-prefix / -xQ</code><br />
Insert space padding <strong>after</strong> the '-' or '+' Objective‑C method prefix. This will add
exactly one space. Any additional spaces will be deleted.</p>
<div class="code">
<pre>-(void)foo1;
- (void)foo2;</pre>
<p class="code">
becomes:</p>
<pre>- (void)foo1;
- (void)foo2;</pre>
</div>
<p>
</p>
<p id="_unpad-method-prefix">
<code class="title">--unpad-method-prefix / -xR</code><br />
Remove all space padding <strong>after</strong> the '-' or '+' Objective‑C method prefix.
This option will be ignored if used with pad‑method‑prefix. This option takes precedence over the
pad paren outside option.</p>
<div class="code">
<pre>- (void) foo1;
- (void) foo2;</pre>
<p class="code">
becomes:</p>
<pre>-(void) foo1;
-(void) foo2;</pre>
</div>
<p>
</p>
<p id="_pad-return-type">
<code class="title">--pad-return-type / -xq</code><br />
Insert space padding <strong>after</strong> the Objective‑C return type. This will add exactly one
space. Any additional spaces will be deleted. </p>
<div class="code">
<pre>-(void)foo1;
-(void) foo2;</pre>
<p class="code">
becomes:</p>
<pre>-(void) foo1;
-(void) foo2;</pre>
</div>
<p>
</p>
<p id="_unpad-return-type">
<code class="title">--unpad-return-type / -xr</code><br />
Remove all space padding <strong>after</strong> the Objective‑C return type. This option
will be ignored if used with pad‑return‑type. This option takes precedence over the pad paren
outside option. </p>
<div class="code">
<pre>-(void) foo1;
-(void) foo2;</pre>
<p class="code">
becomes:</p>
<pre>-(void)foo1;
-(void)foo2;</pre>
</div>
<p>
</p>
<p id="_pad-param-type">
<code class="title">--pad-param-type / -xS</code><br />
Insert space padding around the Objective‑C parameter type. This will add exactly one space. Any additional
spaces will be deleted. This has precedence over the pad method colon option and will always cause space padding
after the method colon.</p>
<div class="code">
<pre>-(void)foo1:(bool)barArg1;
-(void)foo2: (bool) barArg2;</pre>
<p class="code">
becomes:</p>
<pre>-(void)foo1: (bool) barArg1;
-(void)foo2: (bool) barArg2;</pre>
</div>
<p>
</p>
<p id="_unpad-param-type">
<code class="title">--unpad-param-type / -xs</code><br />
Remove all space padding around the Objective‑C parameter type. This option takes precedence over the pad
paren outside option. The pad method colon option has precedence over the <strong>opening</strong> paren. The
closing paren will always be unpadded.</p>
<div class="code">
<pre>-(void)foo1: (bool) barArg1;
-(void)foo2: (bool) barArg2;</pre>
<p class="code">
becomes (with an unpadded method colon):</p>
<pre>-(void)foo1:(bool)barArg1;
-(void)foo2:(bool)barArg2;</pre>
<p class="code">
becomes (with a padded method colon
after):</p>
<pre>-(void)foo1: (bool)barArg1;
-(void)foo2: (bool)barArg2;</pre>
</div>
<p>
</p>
<p id="_align-method-colon">
<code class="title">--align-method-colon / -xM</code><br />
Align the colons in Objective‑C method declarations
and method calls. If this option is not declared, method definitions will be indented uniformly, and method calls
will align with the first keyword.</p>
<div class="code">
<pre>-(void)longKeyword: (ID)theArg1
keyword: (int)theArg2
error: (NSError*)theError
<span class="brace">{</span>
[myObj longKeyword: arg1
keyword: arg2
error: arg3];
<span class="brace">}</span></pre>
<p class="code">
becomes (with no option declared):</p>
<pre>-(void)longKeyword: (ID)theArg1
keyword: (int)theArg2
error: (NSError*)theError
<span class="brace">{</span>
[myObj longKeyword: arg1
keyword: arg2
error: arg3];
<span class="brace">}</span></pre>
<p class="code">
becomes (with
align-method-colon):</p>
<pre>-(void)longKeyword: (ID)theArg1
keyword: (int)theArg2
error: (NSError*)theError
<span class="brace">{</span>
[myObj longKeyword: arg1
keyword: arg2
error: arg3];
<span class="brace">}</span></pre>
</div>
<p>
</p>
<p id="_pad-method-colon">
<code class="title">--pad-method-colon=none / -xP0<br />
--pad-method-colon=all / -xP1<br />
--pad-method-colon=after / -xP2<br />
--pad-method-colon=before / -xP3
</code><br />
Add or remove space padding before or after the colons in an Objective‑C method call. These options will
pad exactly one space. Any additional spaces will be deleted. The space padding after the method colon can be
overridden by pad-param-type.</p>
<div class="code">
<p class="code">
with pad-method-colon=none:</p>
<pre>-(void)insertKey:(id)key;</pre>
<p class="code">
with pad-method-colon=all:</p>
<pre>-(void)insertKey : (id)key;</pre>
<p class="code">
with pad-method-colon=after:</p>
<pre>-(void)insertKey: (id)key;</pre>
<p class="code">
with pad-method-colon=before:</p>
<pre>-(void)insertKey :(id)key;</pre>
</div>
<p>
</p>
<hr />
<!-- * * * * * * * * * * * * Other Command Line Options * * * * * * * * * * * * -->
<h3 id="_Other_Options">Other Options</h3>
<p>
These are non-formatting options available for the command-line. They can also be included in an options
file.</p>
<p id="_suffix">
<code class="title">--suffix=<span class="option">####</span></code><br />
Append the suffix #### instead of '.orig' to original file name (e.g. --suffix=<span class="option">.bak</span>.
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="_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 file path and name in double quotes
so the shell will not resolve the wildcards (e.g. "$HOME/src/*.cpp"). Windows users should place the file path
and name in double quotes if the path or name contains spaces.</p>
<p id="_dry-run">
<code class="title">--dry-run</code><br />
Perform a trial run with no changes made to the files. The report will be output as usual.</p>
<p id="_exclude">
<code class="title">--exclude=<span class="option">####</span></code><br />
Specify a file or subdirectory #### to be excluded from processing.</p>
<p>
Excludes are matched from the end of the file path. 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 file path and name may be placed
in double quotes (e.g. ‑‑exclude="foo bar.cpp").</p>
<p id="_ignore-exclude-errors">
<code class="title">--ignore-exclude-errors / -i</code><br />
Allow processing to continue if there are errors in the "exclude=###" options.<br />
This option lets the excludes for several projects be entered in a single option file. This option may be placed
in the same option file as the excludes. It will display the unmatched excludes. The following option will not
display the unmatched excludes.</p>
<p id="_ignore-exclude-errors-x">
<code class="title">--ignore-exclude-errors-x / -xi</code><br />
<code class="title"></code>Allow processing to continue if there are errors in the "exclude=###" options.<br />
This option lets the excludes for several projects be entered in a single option file. This option may be placed
in the same option file as the excludes. It will NOT display the unmatched excludes. The preceding option will
display the unmatched excludes.</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 a separate output to standard-error, 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 time modified will be changed a few microseconds to
force the changed files to compile. 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, date, 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 Mac OS 9 and earlier. 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>
When <strong>redirection</strong> is used on Windows the output will always have Windows line ends. This option
will be ignored.</p>
<p>
</p>
<hr style="margin-left: -0.4in;" />
<!-- * * * * * * * * * * * * Command-Line Options * * * * * * * * * * * * -->
<h3 id="_Command_Line_Only">Command Line Only</h3>
<p>These options are available for the command-line only. They are NOT available in an options file.</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="_ascii">
<code class="title">--ascii / -I</code><br />
The displayed output will be ASCII characters only. The text will be displayed in English and numbers will not
be formatted. The short option must be by itself, it cannot be concatenated with other options.</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 id="_html">
<code class="title">--html / -!</code><br />
Open the HTML help
file "astyle.html" in the default browser and quit. The short option must be by itself, it
cannot be concatenated with other options. The documentation must be installed in the standard install path (/usr/share/doc/astyle/html
for Linux or %PROGRAMFILES%\AStyle\doc for Windows). If installed to a different path use html=###.</p>
<p id="_html=">
<code class="title">--html=<span class="option">####</span></code><br />
Open an HTML help file in the default browser using the file path #### and quit. An HTML file other than "astyle.help"
may be specified. The path may include a directory path and a file name, or a file name only (e.g. html=install.html).
If only a file name is used, it is assumed to be in the standard install path (/usr/share/doc/astyle/html
for Linux or %PROGRAMFILES%\AStyle\doc for Windows). In both cases the file name must include the html extension.
File paths containing spaces must be enclosed in quotes.</p>
<p>
On Linux the HTML file is opened using the script "xdg-open" from the install package "xdg-utils". This should
be installed by default on most distributions.</p>
<p>
Any HTML file can be opened by this option. The files you are likely to need are astyle.html (the default), install.html,
and index.html.</p>
<p>
</p>
<hr style="margin-left: -0.4in;" />
<p style="margin-left: -0.4in; text-align: center;">
<a href="http://sourceforge.net/projects/astyle">
Artistic Style on SourceForge.net
</a></p>
<p>
</p>
<p>
</p>
</body>
</html>
|