有时候需要编辑代码是通过不同的编辑工具, 其中代码规则及变得很重要了, 例如 tab/空格, {} 是分行还是单独在一行. 缩进到底是几个空格.  使用 astyle 可以定制一种, 然后集成到个IDE或编辑器中, 这样保存的时候附带一个快捷命令即可完成代码格式化.

1. 下载 http://astyle.sourceforge.net/ . 我是在windows下编辑的, 所有直接用 amd64的版本了.
  放在  D:\AStyle
2. 用法在 file:///D:/AStyle/doc/astyle.html  
    我的配置
    D:\AStyle\bin\AStyle.exe --mode=c --style=stroustrup --indent=spaces=4  --attach-namespaces --attach-classes --attach-inlines --attach-extern-c --attach-closing-while --indent-classes --indent-modifiers --indent-switches --indent-namespaces --indent-after-parens --indent-continuation=4 --indent-preproc-block --indent-preproc-define --indent-col1-comments  --max-continuation-indent= --min-conditional-indent=  --pad-oper --pad-comma --pad-header      --align-reference=name --align-pointer=name  --break-closing-braces   --break-one-line-headers  --add-braces --attach-return-type  --convert-tabs --break-after-logical              源文件
12-16 16:51
查看更多