I need to clean the contents of the terminal in Visual Studio Code.
Every time I use Maven, the output of the terminal is attached to the previous build, which is confusing me.
How do I clear the terminal window with some command or keyboard shortcut?
cls
doesn’t work; it only hides the text.
Use Ctrl+K. This goes clean your console in Visual Studio Code.
Per comments, in later versions of VSCode (1.29 and above) this shortcut is missing / needs to be created manually.
- 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
.