什么是Astyle
A Free, Fast, and Small Automatic Formatter for C, C++, C++/CLI, Objective‑C, C#, and Java Source Code
官网
Command prompt
保存成astyle-format.bat
放在文件目录即可.
REM File Name: astyle-format.bat
astyle ^
*.c ^
*.cpp ^
*.h ^
--add-braces ^
--align-method-colon ^
--align-pointer=name ^
--align-reference=name ^
--attach-closing-while ^
--break-blocks ^
--break-elseifs ^
--convert-tabs ^
--delete-empty-lines ^
--indent-col1-comments ^
--indent-continuation=4 ^
--indent-labels ^
--indent-namespaces ^
--indent-preproc-block ^
--indent-preproc-define ^
--indent-switches ^
--indent=spaces=4 ^
--pad-comma ^
--pad-header ^
--pad-oper ^
--recursive ^
--style=java ^
--unpad-paren
注意
- 文件名不能
astyle.cmd
或者astyle.bat
因为上面代码中的astyle
会变成执行astyle.cmd
或者astyle.bat
文件, 会导致死循环 - 当没有
*.c
/*.cpp
/*.h
三者只要有一个文件类型不存在, 命令将不会运行, 你可以手动去掉不存在的文件类型
我是怎么知道的? 打开命令行再输入astyle-format.bat
会报错:
Directory C:UsersPCDesktopprojectpharmacy store management*.c
No file to process *.c
Artistic Style has terminated