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

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

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

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


当前回答

推那个垃圾桶:

当只有一次运行时:

终端再次出现,当使用它,所以杀戮是没有问题的。

其他回答

我在windows 10机器上使用Visual Studio Code 1.38.1。

尝试以下步骤:

退出() PS C:\Users\username> Cls PS C:\Users\ python用户名>

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

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

代码运行器扩展有一个设置“清除以前的输出”,这是我需要的95%的时间。

File > Preferences > Settings > (search for output) > Code-runner:清除以前的输出

剩下的几次,我将禁用该设置,并使用“清除输出”按钮(输出窗格的右上角)来选择性地清除累积的输出。

这是在Visual Studio Code 1.33.1和Code Runner 0.9.8中。

(为Ctrl+k设置键绑定对我来说不起作用,可能是因为某些扩展已经定义了以Ctrl-k开头的“和弦”。但“清除以前的输出”实际上对我来说是一个更好的选择。)

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

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

就是这样。