Introduction to Visual Studio Code
Editor, terminal, Git, notebooks, and Python tooling — everything from Modules 2–6, in one window.
Module 7 · OverviewBy the end of this module you can…
- Explain what an IDE is and why VS Code dominates
- Install VS Code and sign in with your GitHub account
- Configure it through the Settings UI and
settings.json - Use the integrated terminal and the Source Control panel
- Install and use the Python, Jupyter, UV Toolkit, and Ruff extensions
- Set up a project so every collaborator gets the same editor behavior
Meet VS Code
What an IDE is, why this one, and how to install it.
ConceptWhat is an IDE?
An Integrated Development Environment puts every tool a programmer needs in one place:
Editor
Syntax coloring, autocomplete, “go to definition”, multi-file searchTerminal
Your PowerShell, docked beneath the code (Module 2)Version control
Stage, commit, diff, and push without leaving the editor (Module 5)Run & debug
Run scripts, pause on a line, inspect variablesNotebooks
Open and run.ipynb files natively (Module 6)Quality tools
Linters and formatters flag mistakes as you typeSpectrum: Notepad (just text) → VS Code (lightweight editor that grows into an IDE via extensions) → PyCharm / Visual Studio (heavyweight, all-in-one).
Why VS Code?The most popular developer tool on the planet
- Top of the Stack Overflow Developer Survey’s editor rankings year after year
- Free and runs on Windows, macOS, and Linux
- A huge extension marketplace: any language, any tool
- First-class Python and Jupyter support from Microsoft
- Built-in Git and GitHub integration
- Home to most AI coding assistants
Learn one editor well. VS Code skills transfer to any language, any employer, any operating system.
VS Code ≠ Visual Studio. Visual Studio is a separate, much larger IDE mainly for C# and C++. We want Code.
InstallInstalling VS Code
winget install --id Microsoft.VisualStudioCode -e
…or download the User Installer from code.visualstudio.com (no admin needed). On the Additional Tasks screen, tick:
- Add “Open with Code” to the file and folder context menus
- Add to PATH (on by default — keep it)
In a new terminal (PATH changed — Module 3!):
PS> code --version
1.104.2
...
PS> cd C:\actuarial_work\lapse_analytics
PS> code .
code . — “open this folder in VS Code” — is how you’ll start most sessions.
TourFinding your way around
| 1 | Activity bar — switch views: Explorer, Search, Source Control, Run, Extensions |
| 2 | Side bar — the current view (here: your project’s files) |
| 3 | Editor — tabs of open files, side-by-side splits |
| 4 | Panel — Terminal, Problems, Output |
| 5 | Status bar — Git branch, Python version, errors |
🔍
⑂
▷
⊞1
› .venv
› notebooks
› output
.gitignore
check_env.py
pyproject.toml
README.md
uv.lock
import pandas as pd
print("pandas :", pd.__version__)
PS C:\actuarial_work\lapse_analytics> uv run check_env.py
pandas : 2.2.3
TourShortcuts worth learning on day one
| Ctrl+Shift+P | Command Palette — search every command |
| Ctrl+P | Quick-open a file by name |
| Ctrl+` | Show / hide the terminal |
| Ctrl+B | Show / hide the side bar |
| Ctrl+, | Settings |
| Ctrl+Shift+G | Source Control |
| Ctrl+Shift+X | Extensions |
| Ctrl+/ | Comment / uncomment lines |
| Alt+↑ / ↓ | Move line up / down |
| Ctrl+D | Select next match (multi-cursor) |
| F2 | Rename a variable everywhere |
| F12 | Go to definition |
Forgot a shortcut? Ctrl+Shift+P and type what you want. The palette shows the shortcut next to each command.
SetupTrust, and connect GitHub
Workspace Trust
The first time you open a folder, VS Code asks whether you trust its authors. For your own projects: Yes, I trust the authors. For code downloaded from strangers, choose restricted mode.
Sign in with GitHub
- Click the Accounts icon (bottom of the activity bar)
- Backup and Sync Settings… → Sign in with GitHub
- Authorize in the browser window that opens
What you get
- Settings Sync: your settings, shortcuts, and extensions follow you to any PC
- Clone, publish, and open pull requests from inside VS Code
- Many AI assistants sign in through the same account
Pushing and pulling still go through Git and Git Credential Manager (Module 5) — it may ask you to sign in once more.
Configuration
The Settings UI, settings.json, and user vs. workspace scope.
SettingsTwo editors for the same settings
Settings UI — Ctrl+,
- Searchable form: try “auto save” or “font size”
- Tabs for User and Workspace
- A blue bar marks settings you’ve changed
- Great for discovering what exists
settings.json — the text behind the form
- Command Palette → Preferences: Open User Settings (JSON)
- Copy-pasteable, comment-able, version-controllable
- Autocomplete suggests setting names and values
- Great for sharing a known-good setup
| Scope | File | Applies to |
|---|---|---|
| User | %APPDATA%\Code\User\settings.json | Every folder you open |
| Workspace | .vscode\settings.json inside the project | This project only — overrides User; commit it to share with your team |
SettingsA sensible starting settings.json
{
"editor.fontSize": 15,
"editor.rulers": [88],
"files.autoSave": "onFocusChange",
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"terminal.integrated.defaultProfile.windows": "PowerShell",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports.ruff": "explicit"
}
},
"notebook.formatOnSave.enabled": true
}
rulers: a faint guide line at 88 characters (Ruff’s default width)autoSave: saves when you click away — no more unsaved-script surprisesdefaultProfile: terminals open PowerShell 7"[python]": settings for Python files only — format with Ruff and sort imports on save
JSON is strict: every entry except the last needs a comma, and keys need double quotes. VS Code underlines mistakes in red.
Terminal & Source Control
Modules 2 and 5, docked inside the editor.
TerminalThe integrated terminal
- Ctrl+` opens it — already
cd’d into your project folder - + opens another; the ⌄ next to it picks a shell (PowerShell, cmd, Git Bash)
- Split (Ctrl+Shift+5) to run Jupyter on one side, Git on the other
- Right-click a terminal tab to rename or change color
- 🗑 Kill stops the shell and anything running in it; ✕ merely hides the panel
With the Python extension installed, new terminals may auto-activate the project’s .venv — you’ll see (lapse-analytics) before the prompt. uv run works either way.
Just changed PATH or installed a tool? Opening a new terminal tab isn’t enough — VS Code copied the environment at start-up. Quit and restart VS Code.
Source ControlGit without typing — same model underneath
| In VS Code (Ctrl+Shift+G) | Equivalent |
|---|---|
| “Changes” list | git status |
| Click a file → side-by-side view | git diff |
| + next to a file | git add file |
| ↶ Discard changes | git restore file |
| Message box + ✓ Commit | git commit -m |
| Sync / Publish Branch | git push / pull |
- Gutter marks beside line numbers: green = added, blue = modified, red ▸ = deleted
- Timeline (bottom of Explorer): every commit that touched the current file
- “Initialize Repository” button appears for folders without Git
Because you learned the commands first, the buttons aren’t magic: each one is a Git command you already know.
Extensions
Python, Jupyter, UV Toolkit, and Ruff.
ExtensionsInstalling extensions safely
- Ctrl+Shift+X → search by name
- Check the publisher and download count
- Install; some ask you to reload
- Read its Feature Contributions tab for settings and commands
Or from the terminal, by ID:
code --install-extension ms-python.python
code --list-extensions
Extensions run code on your machine with your permissions. Prefer verified publishers (blue tick) and well-known extensions; avoid look-alike names.
Too many extensions slow VS Code down. Install what you use; disable the rest per-workspace.
ExtensionsPython & Jupyter
Python — ms-python.python
- Bundles Pylance (autocomplete, type hints) and the Python Debugger
- ▷ Run Python File button in the editor title
- Detects your project’s
.venv
Jupyter — ms-toolsai.jupyter
- Opens
.ipynbfiles as native notebooks - Same keys as Jupyter Lab: Shift+Enter, A, B, M…
- Variables viewer and data viewer for DataFrames
Point VS Code at the right Python
Scripts: Ctrl+Shift+P → Python: Select Interpreter → choose .venv\Scripts\python.exe. The status bar then shows 3.12.x (.venv).
Notebooks: click Select Kernel (top right) → Python Environments → .venv. The kernel needs ipykernel, which jupyterlab already pulled in.
ExtensionsUV Toolkit
A community extension that brings uv into the editor:
- Command Palette entries for common uv tasks — add/remove packages, sync, run
- Helpers for editing
pyproject.toml - Saves switching to the terminal for routine package management
Install: Extensions view → search “UV Toolkit” → check the publisher → Install. Then type uv in the Command Palette to see what it offers.
Whatever buttons it adds, they run the same uv add, uv sync, uv run you learned in Module 4 — and they edit the same pyproject.toml and uv.lock.
Community extensions evolve quickly. If a feature moves or changes name, the terminal is always there as a fallback.
ExtensionsRuff: linter + formatter
Ruff (by Astral, makers of uv) does two jobs, very fast:
- Lint: flags likely bugs — unused imports, undefined names, shadowed variables
- Format: rewrites code into one consistent style, so nobody argues about spacing
Extension: charliermarsh.ruff. Squiggles appear as you type; formatting runs on save (with our settings.json).
# pyproject.toml — project-wide rules
[tool.ruff]
line-length = 88
[tool.ruff.lint]
select = ["E", "F", "I"] # style, bugs, imports
# Before saving
import pandas as pd, numpy as np
import os
rates={'yr1':0.12,'yr2' : 0.10}
def avg(x) : return sum(x)/len(x)
# After saving: imports sorted & split, code formatted.
# Ruff still underlines all 3 imports: F401 "imported but unused"
import os
import numpy as np
import pandas as pd
rates = {"yr1": 0.12, "yr2": 0.10}
def avg(x):
return sum(x) / len(x)
Also on the CLI: uv add --dev ruff, then uv run ruff check . and uv run ruff format .
TeamworkShare the setup with the project
lapse_analytics\
├── .vscode\
│ ├── settings.json workspace settings
│ └── extensions.json recommended extensions
├── pyproject.toml + [tool.ruff]
└── …
{
"recommendations": [
"ms-python.python",
"ms-toolsai.jupyter",
"charliermarsh.ruff"
]
}
- Commit
.vscode\settings.jsonandextensions.json - A colleague who clones the repo and runs
code .gets a prompt: “Install recommended extensions?” - With Ruff rules in
pyproject.toml, everyone’s code is checked the same way — in the editor and on the CLI
Same idea as uv.lock for packages: make the environment reproducible, not just the code.
Hands-on Lab · 45 minConfigure VS Code for your project
- Install VS Code, sign in with GitHub, and install the four extensions
- Open
lapse_analyticswithcode ., trust it, and select the.venvinterpreter - Add workspace
settings.json,extensions.json, and Ruff rules - Watch Ruff lint and format; run a script; run a notebook
- Stage, commit, and inspect history using only the Source Control panel
Lab · Steps 1–3Install and configure
winget install --id Microsoft.VisualStudioCode -e
# new terminal:
code --install-extension ms-python.python
code --install-extension ms-toolsai.jupyter
code --install-extension charliermarsh.ruff
# UV Toolkit: install from the Extensions view
cd C:\actuarial_work\lapse_analytics
uv add --dev ruff
code .
- Accounts icon → sign in with GitHub
- Yes, I trust the authors
- Python: Select Interpreter →
.venv - Command Palette → Preferences: Open Workspace Settings (JSON) → paste the
"[python]"block from earlier - Create
.vscode\extensions.jsonwith the three recommendations - Add
[tool.ruff]sections topyproject.toml
Lab · Steps 4–5Use it
Lint, format, run
- In
check_env.py, addimport osand squash some spacing:x=[1,2 ,3] - Hover the squiggle under
os— read Ruff’s message. Check the Problems tab. - Save: watch the formatting snap into place. Delete the unused import.
- Click ▷ Run Python File; compare with
uv run check_env.pyin the terminal. - Open
notebooks\01_first_look.ipynb, pick the.venvkernel, Run All.
Commit from the editor
- Ctrl+Shift+G: click each changed file to review its diff
- Stage
.vscode\*andpyproject.toml→ commit “Add VS Code workspace config and Ruff rules” - Stage
check_env.py→ commit “Tidy check script with Ruff” - Open the Timeline for
check_env.py; then confirm withgit log --onelinein the terminal
RecapModule 7 checklist
- I can explain what an IDE adds to a text editor
code .opens my project; I’m signed in with GitHub- I can change settings in the UI and in
settings.json - I know User vs. Workspace settings
- I use the integrated terminal and know when to restart VS Code
- I can stage, commit, and diff from the Source Control panel
- Python, Jupyter, UV Toolkit, and Ruff are installed and working
- My project’s editor config is committed for others
Your First Python Project
Put every tool together — and get a first taste of Python, NumPy, pandas, and charts.