vs code中使用Astyle排版C/C++代码

版权声明:转载请注明出处 https://blog.csdn.net/weixin_43344725/article/details/83068856
  1. 搜索扩展Astyle并安装
  2. 下载Astyle:https://sourceforge.net/projects/astyle/files/,解压缩后添加Astyle.exe的路径到系统环境变量,例如我在Path中增加一条D:\vscode\AStyle_3.1_windows\AStyle\bin
  3. 重启vscode使环境变量生效
  4. 可修改astyle的配置:例如我在用户设置中增加字段
    "astyle.additional_languages": [
        "c",
        "cpp",
    ],
    "astyle.cmd_options": [
        "--style=kr",//Kernighan&Ritchie 风格格式和缩进
        "--indent=spaces=4",//缩进4个空格
        "--convert-tabs",
        "--align-pointer=name",
        "--align-reference=name",
        "--keep-one-line-statements",
        "--pad-header",
        "--pad-oper",//操作符两端插入一个空格
    ],
  1. 对C/C++源文件使用alt+shift+f测试格式重排

猜你喜欢

转载自blog.csdn.net/weixin_43344725/article/details/83068856