Vscode配置

配置项

使用代码格式化(formating)时修改column length

谷歌的代码格式化标准是80列,但是对于现在的电脑屏幕太窄了。这个选项的修改有点隐秘,似乎必须通过settings.json来修改。 在settings.json或者xxx.code-workspace中添加如下内容:

1
2
3
4
5
6
{
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, ColumnLimit: 120 }",
"black-formatter.args": [
"--line-length=100"
] // for python
}

intellisense定义宏(#ifdef)

如果一些宏定义是通过编译时指定,比如gcc/cmake -DDEBUG,那么在vscode中就无法识别这些宏定义,从而导致一些代码提示无法正常工作。需要在vscode_workspace中加入如下配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
"folders": [
{
"path": "../project"
}
],
"settings": {
"C_Cpp.default.includePath": [
],
"C_Cpp.files.exclude": {
"**/.vscode" : true,
},
"C_Cpp.default.defines": [
"DEBUG=True"
],
}
}

设置默认缩进数量

1
2
3
4
5
6
7
{
"settings": {
"editor.tabSize": 4,
"editor.detectIndentation": false,
"editor.insertSpaces": true,
}
}

python debug设置进入文件目录

.code-workspace中加入如下配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File (Integrated Terminal)",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"cwd": "${fileDirname}",
"purpose":["debug-in-terminal"]
}
]
}

如果是在.launch文件,则去掉"launch"层级即可