如何在 Visual Studio 代码中切换终端?
How to switch between terminals in Visual Studio Code?
我希望在 visual studio 代码中打开的终端之间切换。
有了这个 问题,我正确地设置了焦点,但我想在终端之间切换,而不仅仅是从代码到终端。
有办法吗?
仔细一看发现:
{
"key": "shift+cmd+]",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
}
:)
转到 文件 → 首选项 → 键盘快捷键 或只需按 Ctrl + k + Ctrl + s.
然后点击右上角的图标,打开keybindings.json
文件:
尝试将以下两个条目添加到此文件中:
{
"key": "ctrl+pagedown",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
},
{
"key": "ctrl+pageup",
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus"
}
Note: On Mac change ctrl to cmd
alt
+ up/down left/right arrows
在拆分终端之间切换。
如果 alt
取消聚焦您的终端并聚焦菜单,请将其添加到 设置 文件
// settings.json
"window.titleBarStyle": "custom",
"window.customMenuBarAltFocus": false
这是我的方法,它提供了一种在活动终端之间导航以及在终端和编辑器窗格之间跳转的一致方式。您可以尝试将其直接添加到 keybindings.json
,但我建议您通过键绑定 UI(cmd+K cmd+S
on a Mac),这样您就可以 review/manage 冲突等等
有了这个,我可以使用 ctrl+x <arrow direction>
导航到任何可见的编辑器或终端。一旦光标位于终端部分,您可以使用 ctrl+x ctrl+up
或 ctrl+x ctrl+down
循环浏览活动终端(请注意,在屏幕上的拆分终端之间移动是通过 ctrl+x left
或 ctrl+x right
).
cmd-J
仍然习惯于 hide/show 终端面板。
{
"key": "ctrl+x right",
"command": "workbench.action.terminal.focusNextPane",
"when": "terminalFocus"
},
{
"key": "ctrl+x left",
"command": "workbench.action.terminal.focusPreviousPane",
"when": "terminalFocus"
},
{
"key": "ctrl+x ctrl+down",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
},
{
"key": "ctrl+x ctrl+up",
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus"
},
{
"key": "ctrl+x up",
"command": "workbench.action.navigateUp"
},
{
"key": "ctrl+x down",
"command": "workbench.action.navigateDown"
},
{
"key": "ctrl+x left",
"command": "workbench.action.navigateLeft",
"when": "!terminalFocus"
},
{
"key": "ctrl+x right",
"command": "workbench.action.navigateRight",
"when": "!terminalFocus"
},
这是一项正在进行的工作,因为我试图在 VS Code 中模仿我的 emacs 行为,但缺少一些关键元素,比如能够按名称导航到终端缓冲区(不使用 mouse/dropdown).总的来说,我对糟糕的编辑器 group/pane 导航 UX 在一个令人惊叹的产品中感到非常惊讶,但正在努力适应它。
改进@Serhii Popov 的回答
使用 up 和 down 而不是 pageup 和 pagedown
转到 File
→ Preferences
→ Keyboard Shortcuts
或只需按 Ctrl + k + Ctrl + s。
然后点击右上角的图标打开keybindings.json文件:
然后将以下对象添加到文件中的数组中:
[
...
{
"key": "ctrl+down",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
},
{
"key": "ctrl+up",
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus"
}
...
]
注意:在 Mac 上将 ctrl
更改为 cmd
在 Windows
切换终端ctrl
+ ~
切换回代码编辑器 ctrl
+ 1
从 1.56.0 版开始,VS Code 内置了对切换终端的支持:
New keybindings
The terminal has several new default keybindings this release:
- Move to previous terminal -
Ctrl+PageUp (macOS Cmd+Shift+])
- Move to next terminal -
Ctrl+PageDown (macOS Cmd+shift+[)
- Focus terminal tabs view -
Ctrl+Shift+\ (macOS Cmd+Shift+\)
- Terminal tabs preview
As always, these default keybindings can be removed or custom
keybindings can be added via the keybindings system.
在 Windows 10(不确定 Linux 和 Mac):
要在 拆分终端 windows 之间切换 Visual Studio 代码使用
Alt + Right arrow / Left arrow
Ctrl+J可以切换(show/hide)控制台。
您可以为此在 Vs Code 中设置一个简单的自定义键盘快捷键
- 您可以 Ctrl-P 并键入键盘快捷键
- 搜索“终端:切换活动终端”
- 随便设置组合键,我的是Ctrl+K,没用过
现在你可以不使用鼠标切换到侧边栏终端,但如果你只想切换到主终端Ctrl+J
请注意 Group 的 VS Code 概念,因为在阅读此处的一些答案时可能会误导您。
即有不同的默认快捷方式可以在同一组终端(CMD+OPT+up/down)或不同终端组之间切换 (SHIFT+CMD+[ / ])
我希望在 visual studio 代码中打开的终端之间切换。
有了这个
有办法吗?
仔细一看发现:
{
"key": "shift+cmd+]",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
}
:)
转到 文件 → 首选项 → 键盘快捷键 或只需按 Ctrl + k + Ctrl + s.
然后点击右上角的图标,打开keybindings.json
文件:
尝试将以下两个条目添加到此文件中:
{
"key": "ctrl+pagedown",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
},
{
"key": "ctrl+pageup",
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus"
}
Note: On Mac change ctrl to cmd
alt
+ up/down left/right arrows
在拆分终端之间切换。
如果 alt
取消聚焦您的终端并聚焦菜单,请将其添加到 设置 文件
// settings.json
"window.titleBarStyle": "custom",
"window.customMenuBarAltFocus": false
这是我的方法,它提供了一种在活动终端之间导航以及在终端和编辑器窗格之间跳转的一致方式。您可以尝试将其直接添加到 keybindings.json
,但我建议您通过键绑定 UI(cmd+K cmd+S
on a Mac),这样您就可以 review/manage 冲突等等
有了这个,我可以使用 ctrl+x <arrow direction>
导航到任何可见的编辑器或终端。一旦光标位于终端部分,您可以使用 ctrl+x ctrl+up
或 ctrl+x ctrl+down
循环浏览活动终端(请注意,在屏幕上的拆分终端之间移动是通过 ctrl+x left
或 ctrl+x right
).
cmd-J
仍然习惯于 hide/show 终端面板。
{
"key": "ctrl+x right",
"command": "workbench.action.terminal.focusNextPane",
"when": "terminalFocus"
},
{
"key": "ctrl+x left",
"command": "workbench.action.terminal.focusPreviousPane",
"when": "terminalFocus"
},
{
"key": "ctrl+x ctrl+down",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
},
{
"key": "ctrl+x ctrl+up",
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus"
},
{
"key": "ctrl+x up",
"command": "workbench.action.navigateUp"
},
{
"key": "ctrl+x down",
"command": "workbench.action.navigateDown"
},
{
"key": "ctrl+x left",
"command": "workbench.action.navigateLeft",
"when": "!terminalFocus"
},
{
"key": "ctrl+x right",
"command": "workbench.action.navigateRight",
"when": "!terminalFocus"
},
这是一项正在进行的工作,因为我试图在 VS Code 中模仿我的 emacs 行为,但缺少一些关键元素,比如能够按名称导航到终端缓冲区(不使用 mouse/dropdown).总的来说,我对糟糕的编辑器 group/pane 导航 UX 在一个令人惊叹的产品中感到非常惊讶,但正在努力适应它。
改进@Serhii Popov 的回答
使用 up 和 down 而不是 pageup 和 pagedown
转到 File
→ Preferences
→ Keyboard Shortcuts
或只需按 Ctrl + k + Ctrl + s。
然后点击右上角的图标打开keybindings.json文件:
然后将以下对象添加到文件中的数组中:
[
...
{
"key": "ctrl+down",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
},
{
"key": "ctrl+up",
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus"
}
...
]
注意:在 Mac 上将 ctrl
更改为 cmd
在 Windows
切换终端ctrl
+ ~
切换回代码编辑器 ctrl
+ 1
从 1.56.0 版开始,VS Code 内置了对切换终端的支持:
New keybindings
The terminal has several new default keybindings this release:
- Move to previous terminal -
Ctrl+PageUp (macOS Cmd+Shift+])
- Move to next terminal -
Ctrl+PageDown (macOS Cmd+shift+[)
- Focus terminal tabs view -
Ctrl+Shift+\ (macOS Cmd+Shift+\)
- Terminal tabs previewAs always, these default keybindings can be removed or custom keybindings can be added via the keybindings system.
在 Windows 10(不确定 Linux 和 Mac):
要在 拆分终端 windows 之间切换 Visual Studio 代码使用
Alt + Right arrow / Left arrow
Ctrl+J可以切换(show/hide)控制台。
您可以为此在 Vs Code 中设置一个简单的自定义键盘快捷键
- 您可以 Ctrl-P 并键入键盘快捷键
- 搜索“终端:切换活动终端”
- 随便设置组合键,我的是Ctrl+K,没用过
现在你可以不使用鼠标切换到侧边栏终端,但如果你只想切换到主终端Ctrl+J
请注意 Group 的 VS Code 概念,因为在阅读此处的一些答案时可能会误导您。
即有不同的默认快捷方式可以在同一组终端(CMD+OPT+up/down)或不同终端组之间切换 (SHIFT+CMD+[ / ])