VSCode配置astyle代码格式化

在 VSCode 里安装 astyle 插件。
编辑 settings.json 文件,打开管理->设置->扩展->Astyle configuration。
在 settings.json 中加入

"editor.formatOnSave": true,
    "astyle.additional_languages": [
        "c",
        "cpp",
    ],
    "astyle.cmd_options": [
        "--style=allman",
        "--indent=spaces=4",
        "--indent-preproc-block",
        "--pad-oper",
        "--pad-header",
        "--unpad-paren",
        "--suffix=none",
        "--align-pointer=name",
        "--lineend=linux",
        "--convert-tabs",
        "--verbose",
    ],

此处的选项使用的是 RT-Thread 的代码格式化选项。

对当前 C/C++ 文件按 “Ctrl + Shift + I” 即可完成代码格式化。

猜你喜欢

转载自blog.csdn.net/bigfanofloT/article/details/108103626