vscode常用快捷键

1. 介绍

本文主要介绍 vscode 的一些常用快捷键的使用.

2. 打开命令面板

  • 按下 F1 或 Ctrl+Shift+P 可以打开命令面板
    • 在打开的输入框内,可以输入任何命令
      按一下 Backspace 会进入到 Ctrl+P 模式
    • 在 Ctrl+P 下输入 > 可以进入 Ctrl+Shift+P 模式
    • 在 Ctrl+P 窗口下还可以:
      • 直接输入文件名,跳转到文件
      • ? 列出当前可执行的动作
      • ! 显示 Errors 或 Warnings,也可以 Ctrl+Shift+M
      • : 跳转到行数,也可以 Ctrl+G 直接进入
      • @ 跳转到 symbol(搜索变量或者函数),也可以 Ctrl+Shift+O 直接进入
      • @ 根据分类跳转 symbol,查找属性或函数,也可以 Ctrl+Shift+O 后输入:进入
      • # 根据名字查找 symbol,也可以 Ctrl+T

3. 打开配置文件

  • 打开用户设置: Ctrl+Alt+s, 打开配置面板后, 右上角有个 Open Settings(json)可以打开 settings.json.

4. 编辑器与窗口管理

  • 打开一个新窗口: Ctrl+Shift+N
  • 关闭窗口: Ctrl+Shift+W
  • 同时打开多个编辑器(查看多个文件)
  • 新建文件 Ctrl+N
  • 文件之间切换 Ctrl+Tab
  • 切出一个新的分栏编辑器(最多 3 个) Ctrl+\,也可以按住 Ctrl 鼠标点击 Explorer 里的文件名
  • 左中右 3 个分栏编辑器之间切换: Ctrl+1 Ctrl+2 Ctrl+3
  • 编辑器换位置, Ctrl+k 然后按 Left 或 Right

5. 显示相关

  • 全屏:F11
  • zoomIn/zoomOut 放大或缩小窗口:Ctrl +、Ctrl -
  • 侧边栏显/隐: Ctrl+B
  • 显示资源管理器 Ctrl+Shift+E
  • 显示搜索 Ctrl+Shift+F
  • 显示 Git Ctrl+Shift+G
  • 显示 Debug Ctrl+Shift+D
  • 显示 Output Ctrl+Shift+U
  • 隐藏 / 显示侧边栏:Ctrl + b

6. 查找替换

  • 单个文件内查找 Ctrl+F
  • 单个文件内查找替换 Ctrl+H
  • 整个文件夹中查找 Ctrl+Shift+F

7. 修改默认快捷键

打开默认键盘快捷方式设置:File -> Preferences -> Keyboard Shortcuts,或者:Alt+F -> p -> k
修改 keybindings.json

8. 删除上一个单词

要删除前一个单词,可以按 Ctrl + Backspace (Mac: option + delete)。这在你打错字的时候非常有用。

9. 配置参考

keybindings.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
[
{
"key": "ctrl+tab",
"command": "workbench.action.terminal.focusNext", // 切换到下一个终端
"when": "terminalFocus"
},
{
"key": "ctrl+t",
"command": "workbench.action.terminal.new", // 打开新的终端
"when": "terminalFocus"
},
{
"key": "ctrl+1",
"command": "workbench.action.terminal.focusAtIndex1", // 打开终端1
"when": "terminalFocus"
},
{
"key": "ctrl+2",
"command": "workbench.action.terminal.focusAtIndex2",
"when": "terminalFocus"
},
{
"key": "ctrl+3",
"command": "workbench.action.terminal.focusAtIndex3",
"when": "terminalFocus"
},
{
"key": "ctrl+4",
"command": "workbench.action.terminal.focusAtIndex4",
"when": "terminalFocus"
},
{
"key": "ctrl+5",
"command": "workbench.action.terminal.focusAtIndex5",
"when": "terminalFocus"
},
{
"key": "ctrl+6",
"command": "workbench.action.terminal.focusAtIndex6",
"when": "terminalFocus"
},
{
"key": "ctrl+7",
"command": "workbench.action.terminal.focusAtIndex7",
"when": "terminalFocus"
},
{
"key": "ctrl+alt+m",
"command": "workbench.action.toggleMaximizedPanel"
},
{
"key": "ctrl+f5",
"command": "workbench.action.reloadWindow", // 刷新settings.json
"when": "editorTextFocus"
},
{
"key": "alt+down",
"command": "cursorColumnSelectDown",
"when": "textInputFocus"
},
{
"key": "alt+left",
"command": "cursorColumnSelectLeft",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+alt+pagedown",
"command": "cursorColumnSelectPageDown",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+alt+pageup",
"command": "cursorColumnSelectPageUp",
"when": "textInputFocus"
},
{
"key": "alt+right",
"command": "cursorColumnSelectRight",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+alt+up",
"command": "cursorColumnSelectUp",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+b",
"command": "-workbench.action.tasks.build"
},
{
"key": "ctrl+alt+r",
"command": "workbench.files.action.showActiveFileInExplorer"
},
{
"key": "ctrl+e",
"command": "workbench.action.quickOpenLeastRecentlyUsedEditorInGroup"
}
]

10. 参考文档