As a Windows systems admin, I use PowerShell quite a lot. With the release of PS Core, and the implication that the ISE is dead, I've started to try to use VS Code as my day to day tool. One feature I'm missing from ISE is the ability to swap between the editor and the terminal in fullscreen. I usually kept ISE open and maximized, and used Ctrl+R to swap between editor and terminal as needed. I haven't found a way to maximize the terminal, and swap easily between terminal and editor. I know I can make the terminal take up most of the screen, but a) this still leaves about 2 lines of editor open at the top, and b) there doesn't seem to be an easy way to then maximize the editor. Is there a way to minic the ISE behaviour that I haven't found yet?
8 回答
要在全屏编辑器和几乎全屏终端之间切换,您可以使用:
{
"key": "ctrl+alt+m",
"command": "workbench.action.toggleMaximizedPanel"
}
用您选择的键绑定替换Ctrl- Alt- m:那是我的。您只需要先“最大化”终端 - 将其拉到最远。它会在会话之间记住这一点。
重温此:
从 v1.38 开始,这现在非常简单。有两个命令可以将面板/编辑器切换到全屏。
选择一些键绑定用于切换触发器:
{
"key": "ctrl+alt+q",
"command": "workbench.action.toggleMaximizedPanel",
// "command": "workbench.action.toggleEditorVisibility" either one
"when": "!terminalFocus"
},
上述操作会将面板或编辑器扩展至全高,但向后切换将使面板恢复到其原始大小,但不会完全恢复。如果您希望终端在完全打开和完全关闭之间反弹,请尝试以下两种键绑定:
{
"key": "ctrl+alt+t", // you could use "key": "ctrl+`", if you wish
"command": "workbench.action.closePanel",
// "when": "terminalFocus"
},
{
"key": "ctrl+alt+t",
"command": "workbench.action.toggleMaximizedPanel",
"when": "!terminalFocus"
},
上述 2 个键绑定的顺序很重要。
v1.50 正在添加设置panel.opensMaximized
- 我尝试了它的不同选项,但无法获得比ctrl+alt+t
我上面显示的两个键绑定版本更简单的结果。无论如何,请先关闭面板以使其正常工作。
下面概述了阅读@Mark 的答案后我的解决方案,因为它略有不同。我ctrl-alt-m
用来在全尺寸终端和全尺寸编辑器之间切换。
注意:这包括提到的集成终端和 vscode 应用程序菜单栏。
为了后代,我使用的是 vscode 1.40.1 版。
执行
您需要在 vscode 中添加键绑定并执行手动步骤。
keybindings.json
将此添加到您的keybindings.json
文件中,可通过键盘快捷键编辑器访问:
{
"key": "ctrl+alt+m",
"command": "workbench.action.toggleMaximizedPanel",
"when": "!terminalFocus"
},
{
"key": "ctrl+`",
"command": "-workbench.action.terminal.toggleTerminal",
"when": "!terminalFocus"
},
{
"key": "ctrl+alt+m",
"command": "workbench.action.terminal.toggleTerminal",
"when": "terminalFocus"
}
向下滑动集成终端
完成此操作并保存keybindings.json
文件后,您需要在使用 ctrl+` 从编辑器打开后,手动将集成终端滑出底部的屏幕。
之后,您应该能够ctrl+alt+m
在您的编辑器和终端中使用,以获得在它们之间移动的全屏体验。
我已经在本地作为主机在 Ubuntu 和 Fedora 上对此进行了测试,并使用 remote-ssh 从 Windows 10 主机远程连接到 Ubuntu。这还有一个额外的好处,即允许您使用 ctrl+` 从编辑器中获取默认较小的终端,但使用单个命令ctrl+alt+m
, 用于在编辑器/终端之间切换。YMMV!
在 VS Code 中全屏打开终端
此解决方案将替换 VS Code 中的标准键绑定,以便终端全屏切换。
执行
打开命令面板并在方括号之间ctrl+shift+p
搜索并粘贴它。Preferences: Open Keyboard Shortcuts (JSON)
{ "key":"ctrl+j", "command":"workbench.action.toggleMaximizedPanel","when":"!terminalFocus" },
{ "key": "ctrl+oem_3", "command":"workbench.action.toggleMaximizedPanel", "when":"!terminalFocus" }
现在有一个扩展。它是 Samuel T Scott 的“最大化终端”扩展。它重新定义了 ctrl+` 以全屏打开终端。上述键绑定方法也很棒,但根据我的经验,一旦您开始使用“code app.js”之类的 cli 打开文件,它们往往无法正常工作。使用扩展时不会出现此类问题。
对于 macOS 用户,您可以在同一keybindings.json
文件中设置快捷方式。
您可以使用快捷键cmd++shift访问文件p,然后使用 write/select
Preferences: Open Keyboard Shortcuts (JSON)
。在
keybindings.json
中,在方括号之间粘贴以下代码:{ "key": "cmd+alt+m", "command": "workbench.action.toggleMaximizedPanel", "when": "!terminalFocus" }
您可以将快捷方式更改为适合您的任何内容(请注意重写任何默认快捷方式!),但我将我的设置为与其他人建议的相同(cmd+ option+ m)以保持“标准”。
在新选项卡中创建终端并在选项卡之间切换
Ctrl+Shift+P>Terminal: Create New Terminal in Editor Area
创建一个终端作为新选项卡(Aka Editor)。看起来像:
现在您可以使用在选项卡(又名编辑器)和终端(位于新选项卡中)之间切换View: Quick Open Previous Recently Used Editor in Group
在新编辑器组中创建终端并在编辑器组之间切换
Ctrl+Shift+P>Terminal: Create New Terminal in Editor Area to the Side
在新的编辑器组中创建一个终端。看起来像:
现在您可以使用在窗口和终端之间切换View: Navigate Between Editor Groups
笔记:
您可以根据自己的方便将键绑定添加到命令中。
我喜欢这个问题,我相信我找到了一些东西,或者至少得到了我正在寻找的行为。
在此处使用工作区设置:https ://github.com/microsoft/vscode/issues/107624
(输入 ctrl+,然后搜索“openmaximized”并将下拉菜单设置为“always”)
从那里我将“切换终端”的键盘快捷键设置为 ctrl+j (或您可能喜欢的任何东西),现在当我切换终端时,它会从全屏切换到关闭
对于 MacOS,我发现有用cmd++optionm