0

I have a simple HelloWorld.cpp file and I want to run it with the following steps, each is run one after the other as follows.

  • Compile
  • Clear Integrated Terminal
  • Run the produced executable.

Unfortunately I fails to setup the second step (clearing the console window). What is the correct setup?

{ "version": "2.0.0", "tasks": [ { "label": "COMPILE", "command": "cl.exe", "args": [ "/Zi", "/EHsc", "/nologo", "/Fe:", "${fileBasenameNoExtension}.exe", "${file}", "/std:c++latest" ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$msCompile" ] }, { "label": "CLEAN", "command": "cmd.exe /c cls", "dependsOn": "COMPILE" }, { "label": "RUN", "command": "${fileBasenameNoExtension}.exe", "dependsOn": "CLEAN", "options": { "cwd": "${fileDirname}" }, "group": { "kind": "build", "isDefault": true } } ] } 
0

2 Answers 2

1

there is a vscode setting with workbench.action.terminal.clear you'll find related settings there, or in File >Preferences >Keyboard shortcuts. search for Terminal:clear and assign the key

Sign up to request clarification or add additional context in comments.

1 Comment

I want to extend my tasks.json to invoke the 3 steps with just one shortcut CTRL+SHIFT+B.
0

Aha. I found the solution: Add "type": "shell" to the CLEAN step as follows.

{ "type": "shell", "label": "CLEAN", "command": "cls", "dependsOn": "COMPILE" } 

The complete tasks.json.

{ "version": "2.0.0", "tasks": [ { "label": "COMPILE", "command": "cl.exe", "args": [ "/Zi", "/EHsc", "/nologo", "/Fe:", "${fileBasenameNoExtension}.exe", "${file}", "/std:c++latest" ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$msCompile" ] }, { "type": "shell", "label": "CLEAN", "command": "cls", "dependsOn": "COMPILE" }, { "label": "RUN", "command": "${fileBasenameNoExtension}.exe", "dependsOn": "CLEAN", "options": { "cwd": "${fileDirname}" }, "group": { "kind": "build", "isDefault": true } } ] } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.