C/C++代码格式优化工具----astyle

Artistic style is a console program that receives information from the command line. The format of the command line is:

astyle  [options]  SourceFile1  SourceFile2  SourceFile3  [ . . . ]

The block parens [ ] indicate that more than one option or more than one filename can be entered. They are NOT actually included in the command. For the options format see the following Options section.

  Example to format a single file:

astyle  --style=allman  /home/user/project/foo.cpp

  Example to format all .cpp and .h files recursively:

astyle  --style=allman --recursive  /home/user/project/*.cpp  /home/user/project/*.h

Another option will format a single file and change the name:

astyle [options] < OriginalSourceFile > BeautifiedSourceFile

The < and > characters are used to redirect the files into standard input (cin) and out of standard output (cout) - don't forget them! With this option only one file at a time can be formatted. Wildcards are not recognized, there are no console messages, and a backup is not created. On Windows the output will always have Windows line ends.

 

Options

Not specifying any option will result in 4 spaces per indent, no change in bracket placement, and no formatting changes.

Options may be written in two different ways.

Long options

These options start with '--', and must be written one at a time.
(Example: '--brackets=attach --indent=spaces=4')

Short Options

These options start with a single '-', and may be concatenated together.
(Example: '-bps4' is the same as writing '-b -p -s4'.)

Bracket Style Options

default bracket style    style=allman    style=java    style=kr    style=stroustrup   

 style=whitesmith    style=banner   style=gnu    style=linux    style=horstmann    

style=1tbs    style=pico    style=lisp   

Tab Options

default indent    indent=spaces    indent=tab    indent=force‑tab    --indent=force‑tab‑x   

Indentation Options

indent‑classes    indent‑switches    indent‑cases    indent‑namespaces    indent‑labels    

indent‑preprocessor   indent‑col1‑comments    min‑conditional‑indent    max‑instatement‑indent   

Padding Options

break‑blocks    break‑blocks=all    pad‑oper    pad‑paren    pad‑paren‑out    pad‑first‑paren‑out   

 pad‑paren‑in    pad‑header   unpad‑paren    delete‑empty‑lines    fill‑empty‑lines    align‑pointer  

  align‑reference   

Formatting Options

break‑closing‑brackets    break‑elseifs    add‑brackets    add‑one‑line‑brackets    keep‑one‑line‑blocks  

  keep‑one‑line‑statements   convert‑tabs    close‑templates    max‑code‑length    break‑after‑logical   

 mode   

Other Options

suffix    suffix=none    recursive    exclude    ignore‑exclude‑errors    ignore‑exclude‑errors‑x    

errors‑to‑stdout   preserve‑date    verbose    formatted    quiet    lineend   



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值