How to add a Run Button in Visual Studio Code

avatar
Borislav Hadzhiev

Last updated: Apr 6, 2024
2 min

banner

# How to add a Run Button in Visual Studio Code

To add a run button in Visual Studio Code:

  1. Click on Extensions in the left sidebar.
  • You can also open the Extensions menu by pressing:
    • Ctrl + Shift + X on Windows or Linux.
    • Command + Shift + X on macOS.
  1. Type Code Runner.

install code runner extension

  1. Click on the Install button.

Make sure to install the correct Code Runner extension as shown in the code sample.

Once you install the extension, open a file and click the run button to run it.

click on run button

Make sure to save your file before you run it.

You can view a list of the supported languages on the extension's page.

You can also run the file by pressing F1, typing run code and selecting the command.

run code

You can also use a keyboard shortcut to run the file:

  • on Windows and Linux: Ctrl + Alt + N
  • on macOS: Cmd + Option + N

If you hide the run button by mistake, right-click on the three dots ... icon at the top right corner and select Run Code.

click to show run button

# Using the debugger as a run button

You can also use the built-in debugger as a run button.

  1. Click on the Run and Debug icon in the Activity Bar on the left.

click run and debug

You can also use the keyboard shortcut to show the debug pane:

  • on Windows and Linux: press Ctrl + Shift + D
  • on macOS: press Cmd + Shift + D
  1. Set a breakpoint in your code. The breakpoint determines where the debugger should stop.

set breakpoint in your code

  1. Click on Run and Debug.

run code with debugger

  1. The debugger will run your code and will pause at the specified breakpoint.

debugger will run your code

  1. You can use the arrows at the top of the file to step through your code, restart the debugger or stop it.

use arrows to step through your code

You can read more about debugging your code in this section of the official docs.

I've you get the error Linter pylint is not installed error in VS Code, click on the link and follow the instructions.

I've also written an error on how to solve the issue where the Live Server extension doesn't work in VS Code.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.