我需要在Visual Studio代码中清除终端的内容。
每次我使用Maven时,终端的输出都会附加到以前的构建中,这让我感到困惑。
我如何清除终端窗口与一些命令或键盘快捷方式?
CLS不起作用;它只隐藏文本。
我需要在Visual Studio代码中清除终端的内容。
每次我使用Maven时,终端的输出都会附加到以前的构建中,这让我感到困惑。
我如何清除终端窗口与一些命令或键盘快捷方式?
CLS不起作用;它只隐藏文本。
当前回答
使用Ctrl + K。这将在Visual Studio代码中清理控制台。
每个注释,在VSCode(1.29及以上)的后期版本中,这个快捷方式是缺失的/需要手动创建。
Navigate: File > Preferences > Keyboard Shortcuts search for workbench.action.terminal.clear If it has no mapping or you wish to change the mapping, continue; otherwise note & use the existing mapping Double click on this entry & you'll be prompted for a key binding. Hold CTRL and tap K. Ctrl + K should now be listed. Press enter to save this mapping Right click the entry and select Change when expression. Type terminalFocus then press enter. That's it. Now, when the terminal is in focus and you press Ctrl+K you'll get the behaviour you'd have expected to get from running clear/cls.
其他回答
粘贴此命令-
Remove-Item (Get-PSReadlineOption)。HistorySavePath
在你的powershell和启动新的powershell和它发现清除
欲了解更多详情,请查看此链接@ https://www.shellhacks.com/clear-history-powershell/
2019年更新(阅读全文)
快捷方式
Mac: cmd + k
Windows: ctrl + k
故障排除
如果快捷键不适合你,最有可能的情况是你或你安装的扩展程序在另一个快捷键中添加了一个开放的ctrl + k / cmd + k和弦。
开放式的意思是,快捷方式没有排除终端焦点的显式when子句。这里有两种可能的解决方案。
解决方案1:
如果您添加了快捷方式,只需转到您的键绑定。Json文件,并添加一个when子句,不包括终端焦点。例子:
{
"key": "cmd+k cmd+c",
"command": "someCommandHere",
"when": "editorTextFocus",
}
解决方案2:
或者,你可以在键盘绑定的最底部添加workbench.action.terminal.clear命令。Json,确保它优先于其他快捷方式。添加注释是明智的,这样你就不会忘记,然后在下面添加新的和弦。例子:
// Keep this keybinding at very bottom of file to ensure terminal clearing.
{
"key": "cmd+k",
"command": "workbench.action.terminal.clear",
"when": "terminalFocus",
}
欲了解更多信息,请查看此GitHub问题。
V1.33将不接受ctrl + k清除终端(Windows)。
您需要通过在键盘绑定中添加以下代码手动启用。Json,它会覆盖默认值。
在VSCode中,按ctrl + shift + p,搜索键盘,然后点击打开键盘快捷键来打开键盘绑定。json文件。
注意:如果你打开Default文件,它将显示默认设置,但由于该文件是只读的,你不能手动编辑它。
将以下脚本粘贴到keybindings.json中
{
"key": "ctr+k",
"command": "workbench.action.terminal.clear",
"when": "terminalFocus"
}
保存文件。 现在你的终端将被crtl + k清除
点击VS code屏幕左下角的齿轮按钮 然后搜索“终端:清除” 默认情况下没有键盘快捷方式。 只需双击终端:清除 并给出您选择的清除终端的首选快捷方式。 通常使用ctrl+k,因为该快捷键没有与任何命令一起分配。
供参考:这个方法与@SuRa相同,但更简单一点。 顺便说一句:我使用的是VS Code 1.43.0版本
只需在终端(窗口)中输入'clear'即可 或者ctrl+shift+p和 在MAC上-右键单击