vscode+代码格式化工具Astyle配置

1.插件安装

2.配置写入

2.1 windows端vscode

1. PC端安装 Artistic Style软件

2.2 linux(ubuntu)端vscode

3.个人Astyle配置

ubuntu

 windows端


1.插件安装

2.配置写入

2.1 windows端vscode

1. PC端安装 Artistic Style软件

1.1 软件下载
官网地址:http://astyle.sourceforge.net/

选择Download项,得到安装文件(免安装):

解压拷贝到安装路径下得到:其中AStyle.exe是可执行文件,但是不能直接执行,其是命令行模式,因此需要配合其他软件才能执行

记录下文件路径:D:\01_eda_install\AStyle_3.1_windows\AStyle\bin

1.2 添加环境变量
把上述bin文件路径加入 Windows 的 path 环境变量(注意是系统变量不是用户变量)

1.3 安装完毕
重启Windows 使环境变量起作用

Shift + ALT + F 测试是否安装成功

2.写入vscode配置

点击在setting.json中编辑

2.2 linux(ubuntu)端vscode

1.安装Astyle

sudo apt-get install astyle

2.同上windows打开配置文件(.json)

写入配置,就不用再包含astyle的路径了

3.个人Astyle配置

ubuntu

{
    "search.exclude": {
       "**/node_modules": true,
       "**/bower_components": true,
    },
    "files.exclude": {
       "**/.git": true,
       "**/.svn": true,
       "**/.hg": true,
       "**/CVS": true,
       "**/.DS_Store": true,
       "**/*.o": true,
       "**/*.cmd": true,
    },
    "C_Cpp.errorSquiggles": "disabled",
    /* AStyle */
    "astyle.additional_languages": [
       "c",
       "cpp",
       "*.h",
    ],
    "astyle.cmd_options": [
       "--style=google",
       "-s4",
       "-m0",
       "-M40",
       "-k3",
       "-W3",
       "-S",
       "-N",
       "-L",
       "-w",
       "-p",
       "-xg",
       "-H",
       "-U",
       "-xb",
       "-j",
       "-c",
       "-n",
       "--mode=c",
       "--quiet",
   ],
   "[c]": {
      "editor.defaultFormatter": "chiehyu.vscode-astyle"
   },
   "gitlens.advanced.messages": {
      "suppressCreatePullRequestPrompt": true
   },
   "git.confirmSync": false,
   "astyle.astylerc": "",
 }

 windows端

{
    "editor.mouseWheelZoom": true,    //鼠标放大的
    "editor.rulers": [80],            //设置标尺
    "astyle.additional_languages": [
        "c",
        "cpp",
    ],
    "astyle.cmd_options": [
        // 预定义风格 -----------------------------------------------------------
        //"--style=ansi",             //ANSI 风格格式和缩进
        //"--style=kr",               //Kernighan&Ritchie 风格格式和缩进
        "--style=linux",            //Linux 风格格式和缩进
        //"--style=gnu",              //GNU 风格格式和缩进
        //"--style=java",             //Java 风格格式和缩进
 
        "--indent=spaces=2",          //缩进4个空格
        "--indent-preproc-block",
        "--pad-oper",               //操作符两端插入一个空格
        "--pad-header",
        "--unpad-paren",
        "--suffix=none",
        "--align-pointer=name",
        "--lineend=linux",
        "--convert-tabs",         //TAB转换为空格
        "--verbose",
        "--delete-empty-lines",   //删除多余空行
        //"--pad-paren-in",         //括号内部加入空格
        "--unpad-paren",          //移除括号两端多余空格
    ],
    "astyle.executable": "D:\\01_eda_install\\AStyle_3.1_windows\\AStyle\\bin\\AStyle.exe",
    //"files.encoding":"GB2312",//文件编码的,以防中文乱码
    "files.encoding":"UTF-8",
    "[c]": {
        "editor.defaultFormatter": "chiehyu.vscode-astyle"
    },
    "C_Cpp.updateChannel": "Insiders"
}

接下来可以 shift+alt+f 愉快玩耍啦!!!!!!!!

  • 5
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值