zoukankan      html  css  js  c++  java
  • 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:UsersPCDesktopprojectpharmacy store management*.c
    No file to process *.c
    Artistic Style has terminated

  • 相关阅读:
    oracle 存储过程
    交错数组
    延迟加载
    js 闭包
    引用类型和值类型
    事务
    web api 之身份验证
    SQLServer中的服务器角色与数据库角色
    按照某一字段的相同值合并所对应的行的值
    VC工程中的字符集工程属性和字符编码(转)
  • 原文地址:https://www.cnblogs.com/codworm/p/12430427.html
Copyright © 2011-2022 走看看