简体   繁体   中英

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?

In PowerShell ISE for example it's : Ctr+D terminal and Ctr+I code

Can't find anything similar for 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). You open up your keybindings.json* file and add the text below between the square brackets. Once complete, you can use Ctrl+` to move focus back and forth between the code and the terminal.

*File > Preferences > Keyboard Shortcuts and click on 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.

settings.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

[
  // 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"
  },
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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