Is there any shortcut key in vscode to compile C++ code , like vim or atom has f5 ? Press the key and you have a black dialog window . I use vscode for competitive programming and I compile code using "g++" syntax on command prompt . Any method faster than this will work .
Asked
Active
Viewed 1,373 times
1
-
https://code.visualstudio.com/docs/cpp/config-msvc – Dec 13 '20 at 20:15
-
Could be useful: [Execute a bat file on keypress in VsCode](https://stackoverflow.com/a/59849230/2752075) – HolyBlackCat Aug 13 '21 at 17:18
1 Answers
3
You need to install the extension called "Code Runner". To do that :
- Click on the four squares with one square not align icon on the left.
- Type "Code Runner", find the extension and install it.
- Also install the "C/C++" extension.
- When both extensions are installed, to compile and run, press Ctrl + Alt + n.
Small tip : If you want to use VS Code for competitive programming, you might want to change where the code runs to the terminal. As default, the c++ code will get executed in the "output" window but that is a output-only window, so you will not be able to test inputs. To run the code in the terminal (in which you can output/input) follow these steps :
- Go to the Code Runner extension settings
- Search for "run in terminal" and click in the small square.

Brooke Jackson
- 148
- 5
-
-
Do you mean I should use paragraphs or lists to make my answer clearer or someting more involved like colors or images ? – Brooke Jackson Aug 13 '21 at 16:48
-
I've put lists now, is it better or do you have other propositions to make my answer better ? – Brooke Jackson Aug 13 '21 at 17:04
-
@Brooke Jackson I have a problem with thi cmd. When I running it nothing happens, only this line `[Running] cd "c:\git\Cprata\" && gcc test.c -o test && "c:\git\Cprata\"test` apper in OUTPUT ? – Dmitriy Ogureckiy Jun 30 '22 at 17:09