📄 astyle.html
字号:
<div class="code"> <pre>class foospace <span class="brace">{</span> int Foo() <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> </div> <hr /> <!-- * * * * * * * * * * * * Tab and Bracket Options * * * * * * * * * * * * --> <h3 id="_Tab_and_Bracket_Options">Tab and Bracket Options</h3> <div class="options"> <p id="_default_indent"><code class="title">default indent option</code><br /> If no indentation option is set, the default option of <strong>4 spaces</strong> will be used (e.g. <code>-s<span class="option">4</span> --indent=spaces=<span class="option">4</span></code>).</p> <p id="_indent=spaces"><code class="title">--indent=spaces / --indent=spaces=<<span class="option">#</code> / -s<span class="option">#</span><br /> Indent using <code><span class="option">#</span></code> spaces per indent (e.g. <code>-s<span class="option">6</span></code> <code>--indent=spaces=<span class="option">6</span></code>). <span class="option">#</span> must be between <strong>1</strong> and <strong>20</strong>. Not specifying <code><span class="option">#</span></code> will result in a default of <strong>4 spaces</strong> per indent.</p> <p id="_indent=tab"><code class="title">--indent=tab / --indent=tab=<span class="option">#</span> / -t<span class="option">#</span></code><br /> Indent using tab characters. Treat each tab as <code><span class="option">#</span></code> spaces (e.g. <code>-t<span class="option">6</span></code> / <code>--indent=tab=<span class="option">6</span></code>). <span class="option">#</span> must be between <strong>1</strong> and <strong>20</strong>. If no <code><span class="option">#</span></code> is set, treats tabs as <strong>4 spaces</strong>.</p> <p id="_force-indent=tab"> <code class="title">--force-indent=tab=<span class="option">#</span> / -T<span class="option">#</span></code><br /> Indent using tab characters. Treat each tab as <code><span class="option">#</span></code> spaces (e.g. <code>-T<span class="option">6</span></code> / <code>--force-indent=tab=<span class="option">6</span></code>). Uses tabs as indents where <code>--indent=tab</code> prefers to use spaces, such as inside multi-line statements. <span class="option">#</span> must be between <strong>1</strong> and <strong>20</strong>. If no <code><span class="option">#</span></code> is set, treats tabs as <strong>4 spaces</strong>.</p> <p id="_default_brackets"><code class="title">default brackets option</code><br /> If no brackets option is set, the brackets <strong>will not be changed.</strong></p> <p id="_brackets=break"><code class="title">--brackets=break / -b</code><br /> Break brackets from their pre-block statements ( e.g. ANSI C / C++ style ).</p> <div class="code"> <pre>void Foo(bool isFoo)<span class="brace">{</span> if (isFoo)<span class="brace"> {</span> bar();<span class="brace"> }</span> else<span class="brace"> {</span> anotherBar();<span class="brace"> }</span><span class="brace">}</span></pre> </div> <p> </p> <p id="_brackets=attach"><code class="title">--brackets=attach / -a</code><br /> Attach brackets to their pre-block statements ( e.g. Java / K&R style ).</p> <div class="code"> <pre>void Foo(bool isFoo) <span class="brace">{</span> if (isFoo) <span class="brace">{</span> bar();<span class="brace"> }</span> else <span class="brace">{</span> anotherBar();<span class="brace"> }</span><span class="brace">}</span></pre> </div> <p> </p> <p id="_brackets=linux"><code class="title">--brackets=linux / -l</code><br /> Break brackets from class and function declarations, but attach brackets to pre-block command statements.</p> <div class="code"> <pre>void Foo(bool isFoo)<span class="brace">{</span> if (isFoo) <span class="brace">{</span> bar();<span class="brace"> }</span> else <span class="brace">{</span> anotherBar;<span class="brace"> }</span><span class="brace">}</span></pre> </div> <p> </p> <p id="_brackets=break-closing"><code class="title">--brackets=break-closing / -y</code><br /> When used with either <code>--brackets=attach</code> or <code>--brackets=linux</code>, breaks closing headers (e.g. '<code>else</code>', '<code>catch</code>', ...) from their immediately preceding closing brackets.</p> <div class="code"> <pre>void Foo(bool isFoo) <span class="brace">{</span> if (isFoo) <span class="brace">{</span> bar();<span class="brace"> }</span> else <span class="brace">{</span> anotherBar();<span class="brace"> }</span><span class="brace">}</span></pre> <p>becomes (with 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> </div> <hr /> <!-- * * * * * * * * * * * * * Indentation Options * * * * * * * * * * * * * --> <h3 id="_Indentation_Options">Indentation Options</h3> <div class="options"> <p id="_indent-classes"><code class="title">--indent-classes / -C</code><br /> Indent '<code>class</code>' and '<code>struct</code>' blocks so that the blocks '<code>public:</code>', '<code>protected:</code>' and '<code>private:</code>' are indented. The entire block is indented. This option has no effect on Java and C# files.</p> <div class="code"> <pre>class Foo<span class="brace">{</span>public: Foo(); virtual ~Foo();<span class="brace">}</span>;</pre> <p>becomes:</p> <pre>class Foo<span class="brace">{</span> public: Foo(); virtual ~Foo();<span class="brace">}</span>;</pre> </div> <p> </p> <p id="_indent-switches"><code class="title">--indent-switches / -S</code><br /> Indent '<code>switch</code>' blocks so that the '<code>case X:</code>' statements are indented in the <code>switch</code> block. The entire case block is indented.</p> <div class="code"> <pre>switch (foo)<span class="brace">{</span>case 1: a += 1; break;case 2:<span class="brace">{</span> a += 2; break;<span class="brace">}</span><span class="brace">}</span></pre> <p>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></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></pre> <p>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></pre> </div> <p> </p> <p id="_indent-blocks"><code class="title">--indent-blocks / -G</code><br /> Add extra indentation to entire blocks.</p> <div class="code"> <pre>if (isFoo)<span class="brace">{</span> bar();<span class="brace">}</span>else anotherBar();</pre> <p>becomes:</p> <pre>if (isFoo)<span class="brace"> {</span> bar();<span class="brace"> }</span>else anotherBar();</pre> </div> <p> </p> <p id="_indent-brackets"><code class="title">--indent-brackets / -B</code><br /> Add extra indentation to brackets. This option has no effect if <code>--indent-blocks</code> is used.</p> <div class="code"> <pre>if (isFoo)<span class="brace">{</span> bar();<span class="brace">}</span>else anotherBar();</pre> <p>becomes:</p> <pre>if (isFoo)<span class="brace"> {</span> bar();<span class="brace"> }</span>else anotherBar();</pre> </div> <p> </p> <p id="_indent-namespaces"><code class="title">--indent-namespaces / -N</code><br /> Add extra indentation to namespace blocks.</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>becomes:</p> <pre>namespace foospace<span class="brace">{</span> class Foo<span class="brace"> {</span> public: Foo(); virtual ~Foo();<span class="brace"> }</span>;<span class="brace">}</span></pre> </div> <p> </p> <p id="_indent-labels"><code class="title">--indent-labels / -L</code><br /> Add extra indentation to labels so they appear 1 indent less than the current indentation, rather than being flushed to the left (the default).</p> <div class="code"> <pre>int foo() <span class="brace">{</span> while (isFoo) <span class="brace">{</span> ... if (isFoo) goto error;<span class="brace"> }</span>error: ...<span class="brace">}</span></pre> <p>becomes (with indented 'error'):</p> <pre>int foo() <span class="brace">{</span> while (isFoo) <span class="brace">{</span> ... if (isFoo) goto error;<span class="brace"> }</span> error: ...<span class="brace">}</span></pre> </div> <p> </p> <p id="_indent-preprocessor"><code class="title">--indent-preprocessor / -w</code><br /> Indent multi-line preprocessor definitions ending with a backslash. Should be used with <strong><code>--convert-tabs</code></strong> for proper results. Does a pretty good job, but can not perform miracles in obfuscated preprocessor definitions.</p> <div class="code"> <pre>#define Is_Bar(arg,a,b) \(Is_Foo((arg), (a)) \|| Is_Foo((arg), (b)))</pre> <p>becomes:</p> <pre>#define Is_Bar(arg,a,b) \ (Is_Foo((arg), (a)) \ || Is_Foo((arg), (b)))</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 /> Indent a maximum of <code><span class="option">#</span></code> spaces in a continuous statement, relative to the previous line (e.g. <strong><code>--max-instatement-indent=<span class="option">40</span></code></strong>). <span class="option">#</span> must be less than <strong>80</strong>. If no <code><span class="option">#</span></code> is set, the default value of <strong>40</strong> will be used.</p> <div class="code"> <pre>fooArray[] = <span class="brace">{</span> red, green, blue <span class="brace">}</span>;fooFunction(barArg1, barArg2, barArg3);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -