Как я могу очистить терминал в VSCode?
Каждый раз, когда я использую Maven, вывод терминала привязан к предыдущей сборке, что меня смущает.
Как очистить окно терминала с помощью какой-либо команды или сочетания клавиш?
cls не работает, он только скрывает текст.
36 ответов
Используйте Ctrl + K , чтобы очистить консоль в VScode
Ctrl + Shift + P и выберите Terminal:clear
Это для VSCode v1.18 и до, я верю, я на v1.29.1 , Поскольку, очевидно, существует множество предположений о привязках по умолчанию, вот как вы устанавливаете привязку, а затем используете ее. Имейте в виду, что эта привязка полностью удалит также всю историю в вашем терминале.
Откройте Keyboard Shortcuts с помощью CTRL + K , CTRL + S. Как только вы в Keyboard Shortcuts , нажмите на keybindings.json в тексте, который говорит . open and edit keybindings.json , Тогда на правой стороне, в keybindings.json , добавьте это (убедитесь, что вы ставите запятую перед первым < если уже есть одна или несколько привязок):
Помните, что «key»: может быть любой привязкой, которую вы хотите, это не должно быть CTRL + K
Чтобы использовать связывание клавиш, вы должны сосредоточиться на своем терминале, а затем выполнить связывание.
Чтобы очистить терминал в VS Code, просто нажмите клавиши Ctrl + Shift + P, чтобы открыть командную палитру, и введите команду Terminal: Clear. Также вы перейдете в View в панели задач в левом верхнем углу кода и откройте Command pallete.
Это позволит легко очистить терминал и работать с любым каталогом, который вы открыли в своем терминале. Это для Windows, также попробуйте, если это работает для Mac.
Горячие клавиши Visual Studio Code
В таблице перечислены горячие клавиши по умолчанию, клавиши расширений , и перенастроенные мной .
Мое избранное
LivePreview
Для работы LivePreview должен быть установлен NodeJS.
1. В Visual Studio Code открываем встроенный терминал (Ctrl + ` или Ctrl + J)
2. Ввести: live-server
Страница откроется в браузере по умолчанию. Подробнее тут.
Расширения
Синхронизация настроек Visual Studio Code с Gist
1. Установить расширение: Settings Sync
2. Сгенерировать токен на GitHub по инструкции из расширения
3. В Visual Studio Code нажать Shift + Alt + U и ввести токен
4. Если был введен неверный токен, то можно сбросить настройки, и повторить ввод: F1 —> Sync —> Sync: Reset Extension Settings
5. После ввода токена будет показан Gist ID, который нужно скопировать и сохранить для настройки загрузки на других машинах
6. Скорректировать настрйки расширения в соответствии с теми, что ниже. Для вызова настроек: Ctrl + K Ctrl + S
7. Для вызова настроек Settings Sync использовать сочетание клавиш: F1 —> Sync
Как очистить терминал в VS Code
Как и любой другой современный редактор кода, VS Code имеет встроенный терминал, который обычно используется для демонстрации вывода кода.
Но как очистить терминал?
Ну, самый простой (проверено в Windows и Linux) — навести курсор на терминал и использовать Ctrl + l , чтобы очистить терминал.
Альтернативно вы можете использовать Ctrl + `, чтобы попасть в окно терминала:
Это работает, но занимает немного больше времени. Что делать, если вы хотите использовать любой другой ярлык? В этом уроке я покажу вам, как это сделать.
Очистите терминал в VS Code
Здесь я шаг за шагом расскажу вам, как назначить конкретный ярлык для очистки терминала в VS Code.
Сначала нажмите Ctrl + Shift + p , и откроется редактор команд:

Здесь вам нужно будет найти команду очистки для терминала, набрав в редакторе команд следующее:
И нажмите на маленький значок шестеренки, чтобы увидеть первый результат:

Здесь нажмите значок плюса + , и вам будет предложено создать ярлык для очистки терминала. Вы можете использовать различные варианты, но на всякий случай я выбрал Ctlr + Alt + l , поскольку он не был занят какой-либо другой операцией:

После этого нажмите клавишу Enter , чтобы подтвердить сочетание клавиш, и все!
С этого момента вам не нужно переключаться в окно терминала, чтобы очистить терминал:
Довольно круто. Не так ли?
Ищете больше ярлыков VS Code?
Ярлыки дают вам суперсилу. Освоение правильных сочетаний клавиш сделает вас более эффективным и продуктивным.
Вот список лучших сочетаний клавиш VS Code, которые вам следует знать и освоить.
Кстати, слышали ли вы о VSCodium, полной версии VS Code с открытым исходным кодом?
Я надеюсь, что вы найдете это полезным. А если у вас есть какие-либо вопросы, не стесняйтесь спрашивать в комментариях.
Как очистить терминал в visual studio code
I usually clear the terminal with cmd-k but in VS Code this key combination didn’t work.
I had to use cmd-shift-P and search the Terminal: Clear command.
Turns out I had the cmd-k key combination already set up, but it wasn’t working.
In the keyboard shortcuts screen, the When column was set to terminalFocus && terminalProcessSupported . I set it to just terminalFocus and it worked.
You can also remove terminalFocus to make cmd-k clear the console even if the terminal is not focused, which is nice sometimes.
How to clear the contents of the terminal #23140
The text was updated successfully, but these errors were encountered:
In OSX u can use cmd+k.
Enter command clear , if you are using Mac OS, press Cmd+K.
think you all,but i’m using windows!
@csyj501 ctrl+k should work on Windows
command +k on mac waits for a second key «chord»
is that just me?
@sebbean you need the terminal focused. If it doesn’t work then you have keybindings overriding cmd+k
could be i selected «sublime» key preset
This doesn’t work for me on windows running VSCode version 1.17.2. The Keyboard Shortcuts page says the Clear command is using the default. I get the text ^K in the terminal when I try it.
@ajbeaven I don’t think Windows has a default for this, if you want ctrl+k then add this to your keybindings.json:
@Tyriar Oh, OK. I’m just confused with the following comment you made that everyone seems to be upvoting for some reason.
This should be added to the default keybindings IMO.
@ajbeaven actually that guy’s pretty smart, you should listen to him , ctrl+k should work on Windows, it’s just Linux that it’s disabled on:
If it doesn’t work, you likely have a ctrl+k chord keybinding defined, if that is the case you will need to redefine the ctrl+k keybinding at the bottom of your keybindings.json:
Haha, yes indeed! I’m pretty sure I don’t have any custom bindings already on ctrl+k . If that were the case the Keyboard Shortcuts page would indicate that it was a «User» instead of «Default» like it has now.
How to Clear Terminal in VS Code

Like any other modern code editor, the VS Code has an integrated terminal that is generally used to showcase the output of a code.
But how are you supposed to clear the terminal?
Well, the easiest (tested on Windows and Linux) is to hover the cursor over the terminal and use the Ctrl + l to clear the terminal.
Alternatively, you can use the Ctrl + ` to get into the terminal window:
That works but takes a bit longer. What if you want to use any other shortcut? In this tutorial, I will show you how to do that.
Clear the terminal in VS Code
Here, I will walk you through step by step how you can allocate a specific shortcut to clear the terminal in VS Code.
First, press Ctrl + Shift + p and it will bring you the command editor:

Here, you will have to search for clear command for the terminal by typing the following in the command editor:
And click on the little gear icon for the first result:

Here, click on the plus + icon and it will ask you to create a shortcut to clear the terminal. You may use various options, but in case, I went with Ctlr + Alt + l as it was not occupied by any other operation:

Once done, press the Enter key to confirm the shortcut and that’s it!
From now on, you don’t have to switch to the terminal window to clear the terminal:
Pretty cool. Isn’t it?
Looking for more VS Code shortcuts?
Shortcuts give you a superpower. Mastering correct shortcuts makes you more efficient and helps you become more productive.
Here are a list of best VS Code shortcuts you should know and master.
It's FOSS Community

By the way, have you heard of VSCodium, a complete open source version of VS Code?
It's FOSS Abhishek Prakash

I hope you will find this helpful. And if you have any queries, feel free to ask in the comments.
How can I clear the terminal in Visual Studio Code?
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.
![]()
![]()
33 Answers 33
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 .
Ctrl + Shift + P and select Terminal:clear
![]()
FOR VERSIONS AT AND ABOVE v1.32 SEE BELOW
Bindings for this command still need to be setup manually, even at v1.33.1 , which I am at. The command is there under Terminal: Clear but the binding is blank. Here is how you can setup bindings in v1.32 and up.
Open up the Keyboard Shortcuts with Ctrl + K , Ctrl + S . Then click on the <> next to the Keyboard Shortcuts tab to open up the keybindings.json file.

After doing so, find some open space anywhere in the file, and type in the key bind below.
FOR VERSIONS UP TO v1.32 SEE BELOW
This is for Visual Studio Code v1.18 up to v1.32 , I believe; I am on v1.29.1 . Since apparently there are a whole lot of assumptions about the default bindings, here is how you set up a binding, then use it. Keep in mind this binding will completely delete all of the history in your terminal too.