Document

Header snippet

Astyle 格式化代码

什么是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:\Users\PC\Desktop\project\pharmacy store management*.c
No file to process *.c
Artistic Style has terminated

posted @ 2020-03-06 19:53  codworm  阅读(799)  评论(0编辑  收藏  举报
Document

Footer snippet