简体   繁体   English

VS 代码 - 集成终端 - 在代码和终端之间切换的键盘快捷键?

[英]VS code - integrated terminal - keyboard shortcut to toggle between code and terminal?

Any suggestions how to toggle between code and integrated terminal in VS Code?任何建议如何在 VS Code 中的代码和集成终端之间切换?

In PowerShell ISE for example it's : Ctr+D terminal and Ctr+I code例如,在 PowerShell ISE 中,它是: Ctr+D终端和Ctr+I代码

Can't find anything similar for VS Code.找不到与 VS Code 类似的东西。

Thank you in advance for any suggestions预先感谢您的任何建议

At current, the last post by sqlaide on this thread had a great answer (that works).目前,sqlaide 在此线程上的最后一篇文章有​​一个很好的答案(有效)。 You open up your keybindings.json* file and add the text below between the square brackets.您打开 keybindings.json* 文件并在方括号之间添加以下文本。 Once complete, you can use Ctrl+` to move focus back and forth between the code and the terminal.完成后,您可以使用 Ctrl+` 在代码和终端之间来回移动焦点。

*File > Preferences > Keyboard Shortcuts and click on keybindings.json. *文件 > 首选项 > 键盘快捷键,然后单击 keybindings.json。

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

elaborating on the previous answer, I would like to share my working configuration to switch between Code and Terminal with or without full-sized Terminal.详细阐述上一个答案,我想分享我的工作配置,以便在有或没有全尺寸终端的情况下在代码和终端之间切换。

NOTE: I tested this on my Mac, running VSCode on an EC2 instance.注意:我在我的 Mac 上对此进行了测试,在 EC2 实例上运行 VSCode。

settings.json设置.json

{
  "multiCommand.commands": [
    {
      "command": "multiCommand.move2Terminal",
      "sequence": [
        "workbench.action.toggleMaximizedPanel",
        "workbench.action.terminal.focus"
      ]
    },
    {
      "command": "multiCommand.move2Code",
      "sequence": [
        "workbench.action.toggleMaximizedPanel",
        "workbench.action.focusActiveEditorGroup"
      ]
    }
  ]
}

keybindings.json键绑定.json

[
  // Switch between Terminal and Code
  {
    "key": "shift+cmd+,",
    "command": "workbench.action.terminal.focus",
    "when": "!terminalFocus"
  },
  {
    "key": "shift+cmd+,",
    "command": "workbench.action.focusActiveEditorGroup",
    "when": "terminalFocus"
  }
  // Switch to Terminal full-screen and back to Code
  {
    "key": "shift+cmd+.",
    "command": "extension.multiCommand.execute",
    "args": {
      "command": "multiCommand.move2Terminal"
    },
    "when": "!terminalFocus"
  },
  {
    "key": "shift+cmd+.",
    "command": "extension.multiCommand.execute",
    "args": {
      "command": "multiCommand.move2Code"
    },
    "when": "terminalFocus"
  },
]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM