首页 文章

在Visual Studio Code中切换编辑器和集成终端之间的焦点

提问于
浏览
211

有没有人知道键盘快捷键(Mac和Linux)在Visual Studio Code中切换编辑器和集成终端之间的焦点 .

10 回答

  • 9

    尝试使用 ctrl+` 来切换终端的可见性,从而切换焦点 .

  • 36

    虽然VS Code有很多模态切换和导航快捷方式,但没有一个专门用于"move from editor to terminal, and back again" . 但是,您可以通过重载 key 并使用 when clause来组合这两个步骤 .

    // Toggle between terminal and editor focus
    { "key": "ctrl+`", "command": "workbench.action.terminal.focus"},
    { "key": "ctrl+`", "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus"}
    

    通过这些快捷方式,我将使用相同的按键在编辑器和集成终端之间进行关注 .

  • 486

    比赛有点晚了,但我在 keybindings.json 中将我的配置如下:

    {
        "key": "ctrl+`",
        "command": "workbench.action.terminal.focus",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+`",
        "command": "workbench.action.focusActiveEditorGroup",
        "when": "terminalFocus"
    },
    {
        "key": "alt+`",
        "command": "workbench.action.terminal.toggleTerminal"
    }
    

    我想要单独的键来打开/关闭终端并在窗口之间来回切换焦点 .

  • 1

    我配置我的如下,因为我发现ctrl`有点难按 .

    {
      "key": "ctrl+k",
      "command": "workbench.action.focusActiveEditorGroup",
      "when": "terminalFocus"
    },
    {
      "key": "ctrl+j",
      "command": "workbench.action.terminal.focus",
      "when": "!terminalFocus"
    }
    

    我还配置了以下内容在编辑器组之间移动 .

    {
      "key": "ctrl+h",
      "command": "workbench.action.focusPreviousGroup",
      "when": "!terminalFocus"
    },
    {
      "key": "ctrl+l",
      "command": "workbench.action.focusNextGroup",
      "when": "!terminalFocus"
    }
    

    顺便说一句,我从 System Preferences => keyboard =>Modifier Keys 配置了Caps Lock到Mac上的ctrl .

  • 16

    Ctrl J有效;但也显示/隐藏控制台 .

  • 1

    根据vscode键盘快捷键documentation页面,切换集成终端的默认键绑定是"Ctrl+`" . 如果你不喜欢这种快捷方式,你可以通过添加类似于以下内容的东西在你的keybindings文件中更改它:

    { "key": "ctrl+l", "command": "workbench.action.terminal.toggleTerminal" }
    

    简单地聚焦底部面板似乎没有默认的键绑定 . 因此,如果您不想切换底部面板,则需要在keybindings文件中添加类似以下内容:

    { "key": "ctrl+t", "command": "workbench.action.focusPanel" }
    
  • 2

    从版本:1.26.1(linux)开始,默认情况下不设置快捷方式 . 设置快捷方式

    • 打开键盘快捷键面板[ctrl k,ctrl s]

    • 搜索 Focus Terminal

    enter image description here

    • 设置快捷方式

    对于编辑器焦点已默认设置 .

    enter image description here

  • 7

    不完全是问什么,但我发现它非常有用和相关 .

    如果有人想从一个终端更改为另一个终端也在Visual Studio的集成终端面板中打开,您可以搜索:

    Terminal: Focus Next Terminal

    或者添加以下快捷键,并使用键盘组合更快地完成 .

    {
        "key": "alt+cmd+right",
        "command": "workbench.action.terminal.focusNext",
        "when": "terminalFocus"
      },
      {
        "key": "alt+cmd+left",
        "command": "workbench.action.terminal.focusPrevious",
        "when": "terminalFocus"
      },
    

    我希望它可以帮助别人 .

  • 0

    Shubham Jain的答案现在是使用内置键盘快捷键的最佳选择 .

    我映射
    enter image description here

    到Ctrl;

    并重新映射
    enter image description here

    按Ctrl L

    通过这种方式,您可以在终端和编辑器之间移动焦点,并且切换终端都非常靠近 .

  • 6

    我通过设置>键盘快捷键然后在给出搜索栏类型焦点终端的部分中选择该选项来完成此操作 . 它将要求输入您要为此操作设置的组合 . 做吧至于搜索栏中的编辑器焦点类型“编辑器焦点”,并键入您想要的键 . 如果你出色地添加一把钥匙 . 它可以通过编辑jason删除,如上面的评论中所述

相关问题