Course 0W · Module 7 Introduction to Visual Studio Code
Python for Actuarial Students · Course 0W
Module 7

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
45 min
Tour & configuration
45 min
Configure your project
Part 1

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 search

Terminal

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 variables

Notebooks

Open and run .ipynb files natively (Module 6)

Quality tools

Linters and formatters flag mistakes as you type

Spectrum: 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

1Activity bar — switch views: Explorer, Search, Source Control, Run, Extensions
2Side bar — the current view (here: your project’s files)
3Editor — tabs of open files, side-by-side splits
4Panel — Terminal, Problems, Output
5Status bar — Git branch, Python version, errors
check_env.py — lapse_analytics — Visual Studio Code
📄
🔍
⑂
▷
⊞1
2LAPSE_ANALYTICS
› .venv
› notebooks
› output
  .gitignore
  check_env.py
  pyproject.toml
  README.md
  uv.lock
3import numpy as np
import pandas as pd

print("pandas :", pd.__version__)
4TERMINAL   PROBLEMS   OUTPUT
PS C:\actuarial_work\lapse_analytics> uv run check_env.py
pandas : 2.2.3
⑂ main    ⊗ 0 ⚠ 0     Python 3.12.8 (.venv)5

TourShortcuts worth learning on day one

Ctrl+Shift+PCommand Palette — search every command
Ctrl+PQuick-open a file by name
Ctrl+`Show / hide the terminal
Ctrl+BShow / hide the side bar
Ctrl+,Settings
Ctrl+Shift+GSource Control
Ctrl+Shift+XExtensions
Ctrl+/Comment / uncomment lines
Alt+↑ / ↓Move line up / down
Ctrl+DSelect next match (multi-cursor)
F2Rename a variable everywhere
F12Go 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

  1. Click the Accounts icon (bottom of the activity bar)
  2. Backup and Sync Settings… → Sign in with GitHub
  3. 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.

Part 2

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
ScopeFileApplies to
User%APPDATA%\Code\User\settings.jsonEvery folder you open
Workspace.vscode\settings.json inside the projectThis 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 surprises
  • defaultProfile: 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.

Part 3

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” listgit status
Click a file → side-by-side viewgit diff
+ next to a filegit add file
↶ Discard changesgit restore file
Message box + ✓ Commitgit commit -m
Sync / Publish Branchgit 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.

Part 4

Extensions

Python, Jupyter, UV Toolkit, and Ruff.

ExtensionsInstalling extensions safely

  1. Ctrl+Shift+X → search by name
  2. Check the publisher and download count
  3. Install; some ask you to reload
  4. 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 .ipynb files 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.json and extensions.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

  1. Install VS Code, sign in with GitHub, and install the four extensions
  2. Open lapse_analytics with code ., trust it, and select the .venv interpreter
  3. Add workspace settings.json, extensions.json, and Ruff rules
  4. Watch Ruff lint and format; run a script; run a notebook
  5. 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 .
  1. Accounts icon → sign in with GitHub
  2. Yes, I trust the authors
  3. Python: Select Interpreter → .venv
  4. Command Palette → Preferences: Open Workspace Settings (JSON) → paste the "[python]" block from earlier
  5. Create .vscode\extensions.json with the three recommendations
  6. Add [tool.ruff] sections to pyproject.toml

Lab · Steps 4–5Use it

Lint, format, run

  1. In check_env.py, add import os and squash some spacing: x=[1,2 ,3]
  2. Hover the squiggle under os — read Ruff’s message. Check the Problems tab.
  3. Save: watch the formatting snap into place. Delete the unused import.
  4. Click ▷ Run Python File; compare with uv run check_env.py in the terminal.
  5. Open notebooks\01_first_look.ipynb, pick the .venv kernel, Run All.

Commit from the editor

  1. Ctrl+Shift+G: click each changed file to review its diff
  2. Stage .vscode\* and pyproject.toml → commit “Add VS Code workspace config and Ruff rules”
  3. Stage check_env.py → commit “Tidy check script with Ruff”
  4. Open the Timeline for check_env.py; then confirm with git log --oneline in 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
Up next
Module 8

Your First Python Project

Put every tool together — and get a first taste of Python, NumPy, pandas, and charts.