我需要在Visual Studio代码中清除终端的内容。

每次我使用Maven时,终端的输出都会附加到以前的构建中,这让我感到困惑。

我如何清除终端窗口与一些命令或键盘快捷方式?

CLS不起作用;它只隐藏文本。


当前回答

workbench.action.terminal.clear不再工作(至少对Mac上的VS Code Insiders 1.54)

下面是将CTRL+L映射到默认控制台功能的方法。

{
    "key": "ctrl+l",
    "command": "workbench.action.terminal.sendSequence",
    "args": {"text": "\u000c"},
    "when": "terminalFocus"
}

其他回答

workbench.action.terminal.clear不再工作(至少对Mac上的VS Code Insiders 1.54)

下面是将CTRL+L映射到默认控制台功能的方法。

{
    "key": "ctrl+l",
    "command": "workbench.action.terminal.sendSequence",
    "args": {"text": "\u000c"},
    "when": "terminalFocus"
}

若要永久删除前面的命令,请使用此命令

Set-PSReadlineOption -HistoryNoDuplicates Remove-Item (Get-PSReadlineOption)。HistorySavePath Alt-f7

粘贴此命令-

Remove-Item (Get-PSReadlineOption)。HistorySavePath

在你的powershell和启动新的powershell和它发现清除

欲了解更多详情,请查看此链接@ https://www.shellhacks.com/clear-history-powershell/

您可以从设置菜单更改(至少从版本1.30.2及以上)…

在Mac上,只需点击代码>首选项>设置。

然后搜索“清除”并选中“清除以前的输出”。

试着输入'cls',如果不行,输入'Clear'大写c,没有引号。希望这能有所帮助。