How to run code in VS Code

Jugo Mobile
By
Jugo Mobile
Jugo Mobile is a platform dedicated to high-quality content in gaming, sports, and tech. Engage with high-quality content and connect with fellow enthusiasts and experts. Explore...
8 Min Read

One of the most popular source code editors, Visual Studio Code, commonly called VS Code, is very beginner-friendly. Its easy-to-use interface and advanced features make it a favorite of both beginner and veteran programmers.

If you’re new to VS Code and looking for a simplified guide on how to run code, you’re in the right place. We’ll guide you through setting up the required software and running code using familiar languages ​​such as C/C++ and Python, as well as how to execute command-line arguments.

The shortcut to run code in VS Code

In VS Code, you only need to use one shortcut to run your code. That shortcut is Ctrl + Alt + N. There are a few more ways to run code.

Pressing F1 and then choosing Run code Also works. If you want to write it after pressing F1you are free to do it too.

Users can right click on the text editor and then select Run code in the context menu. With just two clicks, your code will run.

“Run Code” is also an option in the editor title menu and file explorer context menu.

If you want to stop your code from running, the shortcut is Ctrl+Alt+M. Pressing F1 It also allows you to choose the Stop code execution option. This option is also available in the editor title menu and Output channel.

Lastly, you can right click on the Output channel to open the context menu and select Stop code execution.

Learning these shortcuts and methods should make running and stopping code in various situations a little easier.

How to run C code in VS code

In addition to knowing C code and VS Code, you will need to download the C/C++ extension. Without it, you won’t be able to run C code within VS Code.

These are the instructions to run C code in VS Code:

Configure the required software

  1. Start VS code.
    1710185070 572 How to run code in VS Code
  2. Find the C/C++ extension in the extension market.
    1710185070 31 How to run code in VS Code
  3. Install the extension.
    1710185070 101 How to run code in VS Code
  4. Download and install MinGW.
    1710185071 466 How to run code in VS Code
  5. Make sure to install the “Mingw32-base Package” and “Ming32-gcc-g++ Package” options.
    1710185071 126 How to run code in VS Code
  6. Copy the path to the “bin” folder in MinGW.
    1710185071 512 How to run code in VS Code
  7. Go to Windows’ advanced system settings.
    1710185071 259 How to run code in VS Code
  8. Select Environment Variables.
    1710185072 954 How to run code in VS Code
  9. In it system variables p, click Path.
    1710185072 878 How to run code in VS Code
  10. Select Edit.
    1710185072 3 How to run code in VS Code
  11. From here, click New.
    1710185072 241 How to run code in VS Code
  12. Paste the MinGW path and click OK button.
    How to run code in VS Code
  13. Click OK for the other popups.
    1710185072 329 How to run code in VS Code

Encoding in VS code

  1. Create a folder for your C code.
    1710185073 208 How to run code in VS Code
  2. Add the folder to VS Code and then hover over the C code folder and click + button.
    1710185073 327 How to run code in VS Code
  3. Write the name of the file.
    1710185073 853 How to run code in VS Code
  4. Start coding in C.
    1710185073 641 How to run code in VS Code
  5. Run the code with Ctrl + Alt + N or any of the other methods mentioned above.
    1710185074 989 How to run code in VS Code

Once you complete the one-time software setup, you will be able to use VS Code and C language easily. Just make sure the other necessary programs are installed correctly before running the code, especially the packages.

How to run Python code in VS code

Running Python code in VS Code is relatively easy. You will need a Python extension and interpreter. The first is found in the VS Code extensions marketplace, but Python interpreters vary depending on how they are installed.

Before installing the others, you should already have Python on your PC. Verifying it beforehand is also essential.

With the preliminaries out of the way, let’s get into the coding process.

  1. Using a command prompt, create an empty folder and open it.
    1710185074 396 How to run code in VS Code
  2. Open VS Code in the new empty folder.
    1710185074 304 How to run code in VS Code
  3. Choose the Python interpreter that VS Code will use.
    1710185074 196 How to run code in VS Code
  4. Create a Python source file.
    1710185074 157 How to run code in VS Code
  5. Start coding in Python.
    1710185074 968 How to run code in VS Code
  6. Run the Python code by clicking “Play” in the top right corner of your editor.
    1710185074 965 How to run code in VS Code

Which interpreter you install depends on your needs, but VS Code works incredibly well with Python regardless of your choice of interpreter.

How to run JS code in VS code

JavaScript works even better in VS Code because the latter already has JavaScript IntelliSense, refactoring, and additional advanced features for the language. Since VS Code works so well with JS Code, little preliminary setup is needed to get up and running right away.

This is how you will run JavaScript code in VS Code:

  1. Download and install NodeJS on your PC.
    1710185074 365 How to run code in VS Code
  2. Launch VS Code and create a new folder.
    1710185075 759 How to run code in VS Code
  3. Write in JS and name the file with the extension .js.
    1710185075 303 How to run code in VS Code
  4. Save the changes.
    1710185075 219 How to run code in VS Code
  5. Open a VS Code terminal.
    1710185075 340 How to run code in VS Code
  6. Guy “cd yourdirectoryname” to navigate to the JavaScript code.
    1710185075 151 How to run code in VS Code
  7. If you want to check the output of your code, type “node yourfilename” and wait.
    1710185076 631 How to run code in VS Code

Your directory and files will have different names, so we just include them as placeholder names.

There is also an easier way to run JavaScript code:

  1. Install code runner.
    1710185076 404 How to run code in VS Code
  2. Write or open a JavaScript code file.
    1710185076 573 How to run code in VS Code
  3. Run the code with Ctrl + Alt + N or any other method.
    1710185076 69 How to run code in VS Code
  4. The output window will show your code.
    1710185076 631 How to run code in VS Code

If you just want to test a few lines of code and then save them, this method shines. You can finish in a minute and have a file ready to store for future use.

How to run code with arguments in VS code

Command line arguments are for debugging or launching code files, and VS Code fully supports this type of code and debugging. In this p, you will learn how to run code with arguments.

Before doing so, you need to get “launch.json”. If you don’t have it, you can create it by following these steps:

  1. Gonna Run.
    1710185076 178 How to run code in VS Code
  2. Select Add configuration.
    1710185077 570 How to run code in VS Code

The following steps are to execute code with arguments:

  1. Open launch.json and add your arguments.
    1710185077 191 How to run code in VS Code
  2. Select the file to debug.
    1710185077 77 How to run code in VS Code
  3. Click Run and debug to debug your code.
    1710185077 73 How to run code in VS Code

These are the basics of running your code with arguments. In this case, we are talking about Python since it is the simplest example.

Simplified coding

With this knowledge, running code in VS Code should become as natural as breathing, with enough practice. The various languages ​​you can use with VS Code make it a powerful and easy-to-use IDE. As such, many developers highly recommend that aspiring programmers learn how to use it.

Do you like using VS Code? What do you think of the interface? Let us know your opinion in the comments p below.

TAGGED:
Share This Article
Follow:
Jugo Mobile is a platform dedicated to high-quality content in gaming, sports, and tech. Engage with high-quality content and connect with fellow enthusiasts and experts. Explore the latest trends and innovations in our vibrant community. Join us and experience the future today!
Leave a Comment