pbi*_*e42 23 visual-studio-code
我试图弄清楚是否有办法设置一个键绑定,以便在我在内置终端中打开的终端窗口之间快速切换,而不是每次都必须单击下拉选择器.在制作个人密钥绑定时,有没有人知道这个命令,或者我可以看到VSC所有可能命令的列表?先感谢您!
小智 25
如果你想要的东西比使用任意键绑定感觉更流畅,你可以使用Ctrl + Tab和Ctrl + Shift + Tab来进行编辑器切换和终端切换.
通过ctrl+shift+p搜索打开您的keybindings文件keyboard file.然后加..
{
"key": "ctrl+tab",
"command": "workbench.action.openNextRecentlyUsedEditorInGroup",
"when": "editorFocus"
},
{ "key": "shift+ctrl+tab",
"command": "workbench.action.openPreviousRecentlyUsedEditorInGroup",
"when": "editorFocus"
},
{
"key": "ctrl+tab",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
},
{
"key": "ctrl+shift+tab",
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus"
}
Run Code Online (Sandbox Code Playgroud)
Hai*_*ini 12
从微软文档中有一个提示:
提示:如果您广泛使用多个终端,则可以为Key Bindings部分中列出的focusNext,focusPrevious和kill命令添加键绑定,以允许仅使用键盘在它们之间进行导航.
从这里:
其他终端命令可用,可以绑定到首选键盘快捷键.它们是:workbench.action.terminal.focus:聚焦终端.这就像切换,但如果它是可见的,则聚焦终端而不是隐藏它.
workbench.action.terminal.focusNext: Focuses the next terminal instance.
workbench.action.terminal.focusPrevious: Focuses the previous terminal instance.
workbench.action.terminal.kill: Remove the current terminal instance.
workbench.action.terminal.runSelectedText: Run the selected text in the terminal instance.
Run Code Online (Sandbox Code Playgroud)
只需将这些快捷方式分配给您首选的键绑定,就可以了.
这可能不是直接跳到终端的解决方案(例如像vims gt2)但它肯定是一个开始.
编辑:只是玩弄,发现你也可以专注于特定的终端.只需将这些命令添加到您的任何一个keybindings.json,您就可以开始了!
// - workbench.action.terminal.focusAtIndex1
// - workbench.action.terminal.focusAtIndex2
// - workbench.action.terminal.focusAtIndex3
// - workbench.action.terminal.focusAtIndex4
// - workbench.action.terminal.focusAtIndex5
// - workbench.action.terminal.focusAtIndex6
// - workbench.action.terminal.focusAtIndex7
// - workbench.action.terminal.focusAtIndex8
// - workbench.action.terminal.focusAtIndex9
Run Code Online (Sandbox Code Playgroud)
例如
{ "key": "yourkeybinding", "command": "workbench.action.terminal.focusAtIndex1"}
根据海尼的回答,将下面的代码添加到您的keybindings.json
{
"key": "shift+up",
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus"
},
{
"key": "shift+down",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
}
Run Code Online (Sandbox Code Playgroud)
现在,您可以使用shift + down或在终端之间切换shift + up
这是我构建的在OSX上非常适合我的解决方案。
它模拟了编辑器中用于打开新文件(cmd + n)和在选项卡之间(cmd + left | right)切换的快捷方式,并且该快捷方式在终端处于焦点时也适用于终端。
点击cmd+shift+p并键入keyboard以查找Preferences: Open Keyboard Shortcuts File
将以下内容添加到keybindings.json文件中并保存。
{
"key": "cmd+alt+right",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
},
{
"key": "cmd+alt+left",
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus"
},
{
"key": "cmd+n",
"command": "workbench.action.terminal.new",
"when": "terminalFocus"
},
{
"key": "cmd+w",
"command": "workbench.action.terminal.kill",
"when": "terminalFocus"
}
Run Code Online (Sandbox Code Playgroud)
关闭端子(cmd + w)的操作也相同
| 归档时间: |
|
| 查看次数: |
5159 次 |
| 最近记录: |