How can I clear the terminal in Visual Studio Code?

danilo picture danilo · Feb 9, 2018 · Viewed 112.3k times · Source

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.

Answer

Jeterson Miranda Gomes picture Jeterson Miranda Gomes · Feb 9, 2018

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.