微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

代码格式化工具Astyle2

Tab Options

"."小点代表空格,">"大于号代表一个Tab键。

default indent

如果命令行没写tab的参数,那么格式化认是使用4个空格

命令参数:-s4 --indent=spaces=4

void Foo() {
....if (isBar1
............&& isBar2) // indent of this line can be changed with min-conditional-indent
........bar();
}

indent=spaces=3

命令参数:--indent=spaces / --indent=spaces=# / -s#
Indent using # spaces per indent (e.g. -s3 --indent=spaces=3). # must be between 2 and 20. Not specifying # will result in a default of 4 spaces per indent.

void Foo() {
...if (isBar1
.........&& isBar2) // indent of this line can be changed with min-conditional-indent
......bar();
}

indent=tab

命令参数:--indent=tab / --indent=tab=# / -t / -t#
Indent using tabs for indentation, and spaces for continuation line alignment. This ensures that the code is displayed correctly  regardless of the viewer’s tab size. Treat each indent as # spaces (e.g. -t6 / --indent=tab=6). # must be between 2 and 20. If no # is set, treats indents as 4 spaces.

void Foo() {
>   if (isBar1
>   ........&& isBar2)    // indent of this line can be changed with min-conditional-indent
>   >   bar();
}

style=linux, indent=tab=8

void Foo()
{
>       if (isBar1
>       ....&& isBar2)    // indent of this line can NOT be changed with style=linux
>       >       bar();
}

indent=force-tab

命令参数:--indent=force-tab / --indent=force-tab=# / -T / -T#
Indent using all tab 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. -T6 / --indent=force-tab=6). # must be between 2 and 20. If no # is set, treats tabs as 4 spaces.

void Foo() {
>   if (isBar1
>   >   >   && isBar2)    // indent of this line can be changed with min-conditional-indent
>   >   bar();
}

indent=force-tab-x

命令参数:--indent=force-tab-x / --indent=force-tab-x=# / -xT / -xT#

(default tab length of 8 and default indent length of 4)

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 a mix of both tabs and spaces. Tabs will be used to indent, if possible. If a tab indent cannot be used, spaces will be used instead.

This option sets the tab length. Treat each tab as # spaces (e.g. -xT6 / --indent=force-tab-x=6. # must be between 2 and 20. If no # is set, treats tabs as 8 spaces. To change the indent length from the default of 4 spaces the option "indent=force-tab" must also be used.

void Foo() {
....if (isBar1
>       ....&& isBar2)    // indent of this line can be changed with min-conditional-indent
>       bar();
}

原文地址:https://www.jb51.cc/wenti/3281886.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐