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

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

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

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


当前回答

在VS代码中导航:文件>首选项>键盘快捷方式 搜索workbench.action.terminal.clear

双击此条目&将提示您进行键绑定。按住CTRL并点击L, CTRL + L现在应该列出。按“enter”保存映射

就是这样。

其他回答

在kde的konsole中,有一个动作叫做“clear scrollback”。它不仅像往常一样清除终端,而且还删除了之前的行,这样您就不会回滚而感到困惑。

我发现在vs codium你可以打开设置,搜索终端。然后进入“调试”,“调试”-“终端”-“重用前清除”。

在那里设置复选框,每次开始新的调试时,终端滚动历史记录将不会打扰您。

从命令面板中选择打开键盘快捷键,并将以下内容放入键盘快捷键文件:

{
    "key": "cmd+k",
    "command": "workbench.action.terminal.clear",
    "when": "terminalFocus"
}

使用Ctrl+K清除终端。

但是这在Linux Visual Studio Code中是不可能的。

对于Linux,你可以这样做:

通过命令面板:ctrl+shift+p, "tclear"

要在快捷方式中添加这个,复制粘贴到键绑定文件:

{
  "key": "ctrl+k",
  "command": "workbench.action.terminal.clear",
  "when": "terminalFocus"
}

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

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