如何在 VS Code 快速切換 Editor 與 Terminal ?
VS Code 尚未內建此 shortcut
由於 VS Code 內建 terminal,因此我們可以直接在 VS Code 內直接下 command,也因此我們需要一個 shortcut,可快速在 editor 與 terminal 間 toggle。
Version
macOS High Sierra 10.13.3
VS Code 1.19.3
解除 macOS 預設 Shortcut
由於要使用 ctrl + 1 作為 toggle,而預設已經被 macOS 佔用,必須先加以解除。

System Preferences -> Keyboard -> Shortcuts -> Mission Control -> Shortcuts
將 Swtich to Destop 1 ~ 4的 shortcut 加以解除。
新增 Shortcut
VS Code 並沒有內建切換 editor 與 terminal 的 shortcut,必須自行新增。
對於 toggle terminal,VS Code 已經內建 ctrl + `,因此自行建立一個類似的 ctrl + 1,也方便單手即可操作切換 editor 與 terminal

- ⌘ + ⇧ + p 啟動 Command Palette,輸入 shortcut
- 選擇
Preferences: Open keyboard Shortcuts File

VS Code 將開啟 Default Keybinds 與 keybindings.json 兩個檔案。
keybindings.json
1 | { |
將 ctrl + 1 兩個設定貼入 keybindings.json。
第一個設定為當目前 cursor 在 editor 時,ctrl + 1 將 cursor 切換到 terminal。
第二個設定為當目前 cursor 在 terminal 時,ctrl + 1 將 cursor 切換到 editor。
Conclusion
- ctrl + `: toggle 是否顯示 terminal
- ctrl + 1:將 cursor 在 editor 與 terminal 間切換