在visual studio代码中切换终端

时间:2018-01-25 10:29:46

标签: visual-studio-code

我希望在visual studio代码中打开终端。

这个Switch focus between editor and integrated terminal in Visual Studio Code 我正确设置焦点,但我想在终端之间切换,而不仅仅是从代码到终端。

有办法吗?

8 个答案:

答案 0 :(得分:45)

转到文件首选项键盘快捷方式或仅按 Ctrl + k + Ctrl + s

然后单击右上角中的图标,它将打开keybindings.json文件:

Visual Guide

尝试将以下两个条目添加到该文件中:

{
    "key": "ctrl+pagedown",
    "command": "workbench.action.terminal.focusNext",
    "when": "terminalFocus"
},
{
    "key": "ctrl+pageup",
    "command": "workbench.action.terminal.focusPrevious",
    "when": "terminalFocus"
}

注意:在Mac上,将 ctrl 更改为 cmd

答案 1 :(得分:22)

从 1.56.0 版开始,VS Code 内置了对切换终端的支持:

<块引用>

新键绑定

这个版本的终端有几个新的默认键绑定:

  1. 移动到上一个终端 - Ctrl+PageUp (macOS Cmd+Shift+])
  2. 移动到下一个终端 - Ctrl+PageDown (macOS Cmd+shift+[)
  3. 关注终端标签视图 - Ctrl+Shift+\ (macOS Cmd+Shift+\) - 终端标签预览

和往常一样,这些默认键绑定可以删除或自定义 可以通过键绑定系统添加键绑定。

答案 2 :(得分:16)

alt + up/down left/right arrows在拆分的终端之间切换。

答案 3 :(得分:6)

改进@Serhii Popov的答案

上下使用而不是上一页和下一页

转到FilePreferencesKeyboard Shortcuts或只需按Ctrl + k + Ctrl + s。

然后单击右上角的图标以打开keybindings.json文件:

Visual aid

然后将下面的对象添加到文件中的数组中:

[
  ...
  {
    "key": "ctrl+down",
    "command": "workbench.action.terminal.focusNext",
    "when": "terminalFocus"
  },
  {
    "key": "ctrl+up",
    "command": "workbench.action.terminal.focusPrevious",
    "when": "terminalFocus"
  }
  ...
]

注意:在Mac上,将ctrl更改为cmd

答案 4 :(得分:4)

深入了解我找到了它

{
  "key": "shift+cmd+]",
  "command": "workbench.action.terminal.focusNext",
  "when": "terminalFocus"
}

:)

答案 5 :(得分:2)

这是我的方法,它提供了一种在活动终端之间导航以及在终端和编辑器窗格之间跳转的一致方法。您可以尝试将其直接添加到keybindings.json中,但我建议您通过键盘绑定UI(在Mac上为cmd+K cmd+S),以便查看/管理冲突等。

这样,我可以使用ctrl+x <arrow direction>导航到任何可见的编辑器或终端。光标位于终端部分后,您可以使用ctrl+x ctrl+upctrl+x ctrl+down在活动的终端之间循环(请注意,在屏幕上分离的终端之间的移动是通过ctrl+x left或{{1 }}。

ctrl+x right仍用于隐藏/显示终端窗格。

cmd-J

这是一项正在进行的工作,因为我试图模仿VS Code中的emacs行为,但是缺少一些关键元素,例如能够按名称导航到终端缓冲区(无需使用鼠标/下拉菜单)。总的来说,我对本来不错的产品中糟糕的编辑器组/窗格导航UX感到惊讶,但是正在努力适应它。

答案 6 :(得分:0)

这可能对您有帮助

 {
        "key": "ctrl+shift+j",
        "command": "workbench.action.terminal.focusNext"
    },
    {
        "key": "ctrl+shift+k",
        "command": "workbench.action.terminal.focusPrevious"
    }

答案 7 :(得分:0)

在 Windows 上

切换终端ctrl + ~

切换回代码编辑器 ctrl + 1