Visual Studio Code之设置

全局设置

修改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"
    }
]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值