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

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

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

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


当前回答

F1键打开快捷方式为我使用windows 10。然后输入Terminal,你会看到清晰的选项。

其他回答

对于MacBook来说,可能不是Cmd + K…

关于Cmd + K不起作用的情况有很长的讨论。 就我而言,我用

cmd+K +cmd+ K

转到菜单首选项->快捷键->搜索(“清除”)。把单K改成双K…

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"
}

CRTL +退格 它也有用

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清除

使用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.