全局设置
修改VScode方式有UI和JSON两种方式。可以通过以下菜单路径找到(快捷键Ctrl+,
)。JSON方式需要点击右上角小图标。
File -> Preferences -> Settings
默认Shell
"terminal.integrated.automationShell.windows": "C:\\Windows\\System32\\cmd.exe",
"terminal.integrated.automationShell.linux": "/bin/sh",
Terminal字体
"terminal.integrated.fontFamily": "monospace",
"terminal.integrated.fontSize": 14,
"terminal.integrated.fontWeightBold": "normal",
Windows平台下,推荐设定多Shell并设定快捷键。另分享一下,个人觉得Windows Git自带的shell执行Git命令比Msys2更高效。
多Shell
"terminal.integrated.profiles.windows": {
"JavaScript Debug Terminal": null,
"Windows PowerShell": null,
"PowerShell": null,
"Command Prompt": null,
"cmd": {
"path": "C:\\Windows\\System32\\cmd.exe"
},
"git": {
"path": "D:\\Program Files\\Git\\bin\\bash.exe"
},
"bash": {
"path": "D:\\msys64\\usr\\bin\\bash.exe"
},
"zsh": {
"path": "D:\\msys64\\usr\\bin\\zsh.exe"
},
},
工作空间设置
CPP工程
"C_Cpp.errorSquiggles": "Disabled",
"files.exclude": {
".git" : true,
"**/*.linux" : true,
"**/*.windows" : true,
"**/*.code-workspace" : true,
"**/*.o" : true,
"**/*.flags" : true,
"**/*.map" : true,
"**/*.exe" : true,
"Math" : true,
"build" : true,
},
Tab设定
Tab或4 Space大概是水火不相容的两个信仰吧。建议根据自己的喜好在全局设定,然后在工作空间覆盖。从而尊重每个工程的编码习惯。
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
Shell
Windows平台下,每个工程可能需要不同的shell。例如在IAR工程里,笔者只能使用Command Prompt
来调用编译。而Msys2环境下,bash
则兼容更好。另外,工作空间下路径建议使用环境变量,方便其他人能共享设置。
"terminal.integrated.defaultProfile.windows": "bash",
"terminal.integrated.automationShell.windows": "${env:Msys2}/usr/bin/bash.exe",
近期发现,以上的设置莫名其妙的失效了。更新另外一个为Tasks单独shell的办法。
参考文档:Can a task use a different shell than the one specified for the Integrated Terminal?
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// https://code.visualstudio.com/docs/editor/tasks
// for the documentation about the tasks.json format
"version": "2.0.0",
"windows": {
"options": {
"shell": {
"executable": "${env:Msys2}/usr/bin/bash.exe",
"args": [
"-c"
]
}
}
},
}
快捷键
快捷键使很多操作得心应手。简单记录一下个人的快捷键。修改快捷键有UI和JSON两种方式。可以通过以下菜单路径找到(快捷键Ctrl + k Ctrl + s
)。JSON方式需要点击右上角小图标。
File -> Preferences -> Keyboard Shortcuts
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "alt+c t",
"command": "workbench.action.tasks.runTask"
},
{
"key": "alt+c d",
"command": "workbench.action.debug.selectandstart"
},
{
"key": "alt+c r",
"command": "workbench.action.tasks.reRunTask"
},
{
"key": "ctrl+shift+alt+r",
"command": "workbench.action.tasks.test"
},
{
"key": "ctrl+alt+f",
"command": "workbench.action.findInFiles"
},
{
"key": "ctrl+alt+`",
"command": "workbench.action.terminal.newWithProfile"
}
]