vscode添加Astyle

1、安装astyle插件,在应用商城里面一键安装即可。
2、下载astyle的bin文件,并添加到系统环境变量。
3、打开vscode的settings.json,添加以下代码。

{
    "editor.mouseWheelZoom": true,    //鼠标放大的

    "astyle.additional_languages": [
        "c",
        "cpp",
    ],

    "astyle.cmd_options": [
        "--style=allman",//Kernighan&Ritchie 风格格式和缩进
        "--indent=spaces=4",//缩进4个空格
        "--convert-tabs",
        "--align-pointer=name",
        "--align-reference=name",
        "--keep-one-line-statements",
        "--pad-header",
        "--pad-oper",//操作符两端插入一个空格
    ],

    "astyle.executable": "D:\\AStyle\\bin\\astyle.exe",

    "files.encoding":"GB2312",//文件编码的,以防中文乱码

    "[c]": {
        "editor.defaultFormatter": "chiehyu.vscode-astyle"
    },  //这个是插件安装好了就有的
}
  

注意要添加逗号

然后在文件中使用Alt+Shift+F就可以格式化代码啦。

猜你喜欢

转载自www.cnblogs.com/CodeWorkerLiMing/p/10800827.html