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 愉快玩耍啦!!!!!!!!