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

本文翻译自:Switch focus between editor and integrated terminal in Visual Studio Code

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


#1楼

参考:https://stackoom.com/question/2tZQN/在Visual-Studio-Code中在编辑器和集成终端之间切换焦点


#2楼

The default keybinding to toggle the integrated terminal is "Ctrl+`" according to vscode keyboard shortcuts documentation page. 根据vscode键盘快捷键文档页面,用于切换集成终端的默认键盘绑定是“ Ctrl +`”。 If you don't like that shortcut you can change it in your keybindings file by adding something similar to: 如果您不喜欢该快捷方式,则可以通过添加类似于以下内容的方式在键盘绑定文件中对其进行更改:

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

There does not seem to be a default keybinding for simply focusing the bottom panel. 似乎没有默认的按键绑定可用于仅聚焦于底部面板。 So, if you do not want to toggle the bottom panel, you will need to add something similar to the following to your keybindings file: 因此,如果您不想切换底部面板,则需要在键盘绑定文件中添加类似于以下内容的内容:

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

#3楼

While there are a lot of modal toggles and navigation shortcuts for VS Code, there isn't one specifically for "move from editor to terminal, and back again". 尽管有很多用于VS Code的模式切换和导航快捷键,但没有一个专门用于“从编辑器移至终端,然后再返回”。 However you can compose the two steps by overloading the key and using the when clause . 但是,可以通过重载key并使用when 子句来组成两个步骤。

Open the keybindings.json from the editor: CMD-SHIFT-P -> Preferences: Open Keyboard Shortcuts File and add these entries: 从编辑器中打开keybindings.json:CMD-SHIFT-P-> Preferences:打开Keyboard Shortcuts File并添加以下条目:

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

With these shortcuts I will focus between the editor and the Integrated Terminal using the same keystroke. 通过这些快捷方式,我将使用相同的按键在编辑器和集成终端之间集中精力。


#4楼

A little late to the game but I configured mine as the following in the keybindings.json : 游戏有点晚了,但我在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"
}

I wanted separate keys for opening/closing terminal and switching focus back and forth between the windows. 我想要单独的按键来打开/关闭终端以及在窗口之间来回切换焦点。


#5楼

I configured mine as following since I found ctrl + ` is a bit hard to press. 我发现我的ctrl + `有点难按,所以我的配置如下。

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

I also configured the following to move between editor group. 我还配置了以下内容以在编辑器组之间移动。

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

By the way, I configured Caps Lock to ctrl on Mac from the System Preferences => keyboard =>Modifier Keys . 顺便说一句,我在Mac上从System Preferences => keyboard =>Modifier KeysCaps Lock配置为ctrl


#6楼

Is not exactly what is asked, but I found it very useful and related. 并不是完全问什么,但是我发现它非常有用并且相关。

If someone wants to change from one terminal to another terminal also open in the integrate terminal panel of Visual Studio, you can search for: 如果有人想从一个终端更改为另一个终端,并且也在Visual Studio的集成终端面板中打开,则可以搜索:

Terminal: Focus Next Terminal

Or add the following key shortcut and do it faster with keyboard combination. 或添加以下按键快捷方式,并通过键盘组合更快地完成操作。

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

I hope it helps someone else. 我希望它可以帮助其他人。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值