Coding

VS Code Tutorial: Set Up and Run Your First Project

This VS Code tutorial takes you from an empty folder to a saved, running first project in about ten minutes. You create a folder, open it with code ., trust it, add a file in the Explorer, install the Python extension and press Run.

The example uses Python because the official tutorial does, and because one short file shows the whole loop: edit, save, run, read the output. The same editor steps apply to any language. Commands below use the Windows shortcuts; on macOS, Ctrl is usually Cmd. This was checked against the VS Code documentation as of November 2026, and menus can move between releases.

Step 1: Create a folder and open it in VS Code

VS Code works on folders, not single loose files. Everything you open, search and run is scoped to the folder you opened. From a terminal, create one and open it:

mkdir hello
cd hello
code .

The . means "the current folder". VS Code starts with hello as your workspace. If the code command is not found, open VS Code from the Start menu and open the folder from there instead. For what a workspace is and when it matters, see VS Code workspaces explained.

Step 2: Answer the Workspace Trust prompt

When you open a folder VS Code has not seen before, it shows a "Trust this folder" dialog. Workspace Trust decides whether code in the folder, and the extensions acting on it, may run without your approval. Choosing No, I don't trust the authors puts VS Code in Restricted Mode.

In Restricted Mode, text editing still works. These are limited or disabled:

  • the integrated terminal, which asks you to trust the folder when you open one;
  • tasks and debugging, which ask before they run;
  • workspace settings that could point to executables;
  • extensions that have not opted into Workspace Trust.

Your own empty hello folder is safe to trust. For a project you downloaded, read the code first. If you chose not to trust a folder and change your mind, use the banner at the top of the window or the Workspace Trust editor.

Step 3: Learn the layout

The window has a few named areas, and the documentation uses these names:

AreaWhat it does
Activity BarFar left. Switches between views such as Explorer and Extensions.
Primary Side BarHolds the Explorer, which browses, opens and manages the files and folders in your project. Toggle it with Ctrl+B.
EditorThe main area for editing files. You can open several side by side.
PanelBelow the editor. By default it holds output, debug information, problems and the integrated terminal.
Status BarShows information about the open project and the file you are editing.

Two shortcuts are worth learning on day one. Ctrl+P opens Quick Open, which jumps to a file by name. Ctrl+Shift+P opens the Command Palette, where every command has a searchable name; the Command Palette guide covers it in depth.

Step 4: Install the Python extension

Open the Extensions view from the Activity Bar. It is where you install and manage extensions. Search for the Python extension, whose identifier is ms-python.python, and install it. It adds language support and the Run button, but it does not include Python itself. Install Python 3 separately if you have not already.

Step 5: Create a virtual environment and pick an interpreter

A virtual environment keeps this project's packages separate from every other project. Open the Command Palette with Ctrl+Shift+P and run Python: Create Environment. Choose Venv, then pick a Python interpreter when asked. To confirm which interpreter is active, run Python: Select Interpreter from the same palette.

This step is optional for a one-line script, but it is the habit that prevents "it works on my machine" problems later.

Step 6: Create and edit your first file

In the Explorer, select the New File button on the hello folder and name the file hello.py. The .py extension tells VS Code to treat the file as Python. Type this:

msg = "Roll a dice!"
print(msg)

Save with Ctrl+S. VS Code requires an explicit save by default. If you would rather not think about it, choose File > Auto Save. For finer control, set files.autoSave to off, afterDelay, onFocusChange or onWindowChange. The afterDelay option waits 1000 ms by default.

Step 7: Run it

Click the Run Python File play button in the top-right of the editor. VS Code opens a terminal in the Panel, activates the interpreter you selected, and runs python hello.py on Windows or python3 hello.py on macOS and Linux. The terminal prints the result. Example output:

Roll a dice!

That is the whole loop. If you want to run the file by hand, the same command works in the integrated terminal; see how to open and configure the VS Code terminal.

Editing features to try next

Once the first run works, these editing shortcuts from the official editing guide save the most time:

  • Ctrl+Shift+F searches text across every file in the folder.
  • Shift+Alt+F runs Format Document. Format Selection is Ctrl+K Ctrl+F.
  • Ctrl+D selects the word at the cursor, then the next occurrence each time you press it again.
  • Ctrl+Shift+L adds a cursor at every occurrence of the selected text.
  • Alt+Click adds a cursor wherever you click. Ctrl+Alt+Down and Ctrl+Alt+Up add cursors below and above.

Multiple cursors let you rename a variable or edit many similar lines in one pass, which is faster than repeating the same change by hand.

If something goes wrong

  • No Run button. Check the file ends in .py, the Python extension is installed, and an interpreter is selected through Python: Select Interpreter.
  • The terminal will not open or asks to trust the folder. You are in Restricted Mode. Trust the folder from the banner if you know the code is yours.
  • The terminal says Python was not found. Python is not installed or not on your PATH. Install Python 3, reopen VS Code and select the interpreter again.
  • Your edit has no effect when you run. The file was probably not saved. Press Ctrl+S and run again.

Frequently asked questions

Do I need to install Python before following this VS Code tutorial?
Yes, if you want to run the Python example. The Python extension for VS Code does not include an interpreter, so you install Python 3 separately. For plain text, HTML or Markdown files you need nothing beyond VS Code itself.
What does Restricted Mode mean in VS Code?
Restricted Mode is what VS Code uses for a folder you have not trusted. Text editing works, but the terminal, tasks, debugging, workspace settings that could point to executables, and extensions that have not opted into Workspace Trust are limited or disabled. You can switch to trusted from the banner at any time.
Does VS Code save my files automatically?
Not by default. VS Code requires an explicit save with Ctrl+S. To change that, choose File > Auto Save, or set files.autoSave to off, afterDelay, onFocusChange or onWindowChange. The afterDelay option waits 1000 ms by default.
Why does the Run Python File button not appear?
The button shows in the top-right of the editor when the open file is recognised as Python. Check that the file name ends in .py, that the Python extension is installed, and that an interpreter is selected with Python: Select Interpreter in the Command Palette.

Sources