1

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 .

1 Answers1

3

You need to install the extension called "Code Runner". To do that :

  1. Click on the four squares with one square not align icon on the left.
  2. Type "Code Runner", find the extension and install it.
  3. Also install the "C/C++" extension.
  4. 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 :

  1. Go to the Code Runner extension settings
  2. Search for "run in terminal" and click in the small square.