VS Code 用户手册
常用命令
远程环境直开
code --folder-uri=vscode-remote://ssh-remote+HOSTNAME/FOLDER
code --file-uri=vscode-remote://ssh-remote+HOSTNAME/PATH.code-workspace
常用插件
命令行安装插件
code --install-extension vscjava.vscode-java-pack
code --install-extension ms-vscode.csharp
code --install-extension ms-python.python
code --install-extension ms-azuretools.vscode-docker # Docker
code --install-extension eamodio.gitlens
# 远程开发套件
code --install-extension ms-vscode-remote.vscode-remote-extensionpack
常用设置
通过菜单 Code > Preferences > Settings 或者快捷键 Cmd + ,,可以用 JSON 配置 MS Code。
按扩展名指定语法高亮类型
配置 .exp 文件使用 TCL 高亮:
// 为指定扩展名文件关联高亮语言
"files.associations": {
"*.exp": "tcl"
},
添加 vscode 至命令行
Cmd + Shift + p 选择 Shell Command : Install code in PATH,在命令行中即可使用 code 启动 VS Code。
Kubernets
跳过 resource limits 提醒:
"disable-linters": [
"resource-limits"
]
XML Tools
Azure Portal 上下载的 .PublishSettings 文件没有换行,可以安装 XML Tools 后使用快捷键 Ctrl + Shift + Option + B 重新格式化当前打开的 XML 文件,结合以下设置,可使每个属性在独立一行,方便参考。
// 指定 XML 属性独立一行
"xmlTools.splitAttributesOnFormat": true
Log Viewer
监视对象在 VS Code 配置文件中定义:
{
"logViewer.watch": [
{
"title": "nginx access",
"pattern": "/var/log/nginx/access*.log"
},
{
"title": "nginx error",
"pattern": "/var/log/nginx/error*.log"
}
]
}
快捷键
编辑
Ctrl / Cmd + D 多光标编辑
Ctrl + Shift + Option / Alt + B 格式化 XML 文件,需要安装 XML Tools 插件
Option + ↑ 移动代码行或代码块
切换光标
// 命令行与编辑文档间
{ "key": "ctrl+`", "command": "workbench.action.terminal.focus"},
{ "key": "ctrl+`", "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus"}