This guide explains how to set up and use Visual Studio Code for developing the Weather CLI C++ project.
Download and install VS Code:
When you open the project in VS Code, you'll be prompted to install recommended extensions. Click Install All or install them manually:
Required:
- C/C++ (
ms-vscode.cpptools) - IntelliSense, debugging, code browsing - CMake Tools (
ms-vscode.cmake-tools) - CMake integration - CMake (
twxs.cmake) - CMake language support
Recommended:
- GitHub Copilot (
github.copilot) - AI pair programming - GitHub Copilot Chat (
github.copilot-chat) - AI chat assistant
macOS:
brew install cmake
xcode-select --install # For C++ compilerLinux:
sudo apt-get install build-essential cmake gdbWindows:
- CMake 3.20+, MinGW GCC, libcurl (auto-installed by
scripts\setup-windows.bat) - Or manually:
choco install mingw cmake curl
- Open VS Code
- File → Open Folder...
- Select
copilot-cppdirectory - When prompted, install recommended extensions
- CMake Tools will auto-configure the project
Configure:
- Press
Cmd+Shift+P(macOS) orCtrl+Shift+P(Windows/Linux) - Type "CMake: Configure"
- Select your compiler kit (e.g., GCC, Clang, or Visual Studio)
Build:
- Press
Cmd+Shift+P/Ctrl+Shift+P - Type "CMake: Build"
- Or click Build in the status bar
Quick Build:
- Press
Cmd+Shift+B(macOS) orCtrl+Shift+B(Windows/Linux) - Select "CMake: Build"
Press Cmd+Shift+P / Ctrl+Shift+P and run:
- Tasks: Run Build Task → "CMake: Build"
- Tasks: Run Task → "CMake: Clean Rebuild" (clean build)
Open integrated terminal (`Ctrl+``) and run:
# macOS/Linux
make build
# Windows
mingw32-make build- Open src/main.cpp
- Press
F5or click Run → Start Debugging - Select debug configuration:
- Debug Weather CLI (macOS/Linux)
- Debug Weather CLI (Windows)
Press Cmd+Shift+P / Ctrl+Shift+P:
- Tasks: Run Task → "Run Weather CLI"
This will build and run with default city (London).
# macOS/Linux
./build/weather_cli London
# Windows
.\build\weather_cli.exe London- Set breakpoints by clicking left of line numbers
- Press
F5to start debugging - Choose configuration:
- Debug Weather CLI (macOS/Linux)
- Debug Weather CLI (Windows)
Debug with different city:
- Edit .vscode/launch.json
- Change
"args": ["London"]to your city - Save and press
F5
- Open a test file (e.g., tests/test_weather_service.cpp)
- Set breakpoints
- Press
F5and select:- Debug Tests (macOS/Linux)
- Debug Tests (Windows)
Debug specific test:
- Press
F5and select Debug Current Test - Enter test filter (e.g.,
WeatherServiceTest.*)
- F5 - Start/Continue
- F10 - Step Over
- F11 - Step Into
- Shift+F11 - Step Out
- Shift+F5 - Stop
- Click Testing icon in sidebar (flask icon)
- View all tests in Test Explorer
- Click
▶️ next to a test to run it - Right-click → Debug Test to debug
Press Cmd+Shift+P / Ctrl+Shift+P:
- Tasks: Run Task → "CTest: Run All Tests"
# macOS/Linux
ctest --test-dir build -V --output-on-failure
# Windows
ctest --test-dir build -C Debug -V --output-on-failureIntelliSense is auto-configured via CMake Tools. If you see errors:
- Press
Cmd+Shift+P/Ctrl+Shift+P - Run "CMake: Configure"
- Run "C/C++: Reset IntelliSense Database"
Manual configuration (if needed):
- Edit .vscode/c_cpp_properties.json
- Add missing include paths
Cmd+Shift+B/Ctrl+Shift+B- BuildF5- Start DebuggingCtrl+F5- Run Without Debugging
Cmd+P/Ctrl+P- Quick file openF12- Go to DefinitionShift+F12- Find All ReferencesAlt+Left/Right- Navigate Back/Forward
Cmd+//Ctrl+/- Toggle CommentShift+Alt+F- Format DocumentF2- Rename Symbol
- `Ctrl+`` - Toggle Terminal
Cmd+Shift+\`` /Ctrl+Shift+`` - New Terminal
Already enabled in .vscode/settings.json:
"editor.formatOnSave": trueFormat current file:
- Press
Shift+Alt+F(macOS:Shift+Option+F)
Format all files:
- Run task: "Format Code (clang-format)"
Edit .vscode/settings.json:
"cmake.configureSettings": {
"CMAKE_BUILD_TYPE": "Debug", // or "Release"
"BUILD_TESTS": "ON"
}- Click CMake kit in status bar
- Choose compiler:
- GCC (Linux)
- Clang (macOS/Linux)
- GCC (MinGW) (Windows)
Windows uses MinGW GCC with the Unix Makefiles generator. No manual configuration is needed after running scripts\setup-windows.bat.
If CMake Tools prompts for a kit, select GCC (the MinGW one). The kit scan finds g++.exe automatically once MinGW is on your PATH.
Solution:
- Build the project first:
Cmd+Shift+B - CMake will fetch dependencies
- Run "CMake: Configure"
- Restart VS Code if needed
Solution:
- Click No Kit Selected in status bar
- Choose appropriate compiler kit
- Or run "CMake: Select a Kit" from command palette
Solution:
- Run setup script:
scripts\setup-windows.bat(as Administrator) - Or manually:
choco install mingw cmake curl - See WINDOWS_GETTING_STARTED.md for full troubleshooting
Solution:
- Build the project first
- Enable test explorer in settings:
"cmake.testExplorer.enabled": true
- Reload VS Code
Solution:
- Build project first:
Ctrl+Shift+B - Check the executable exists:
- macOS/Linux:
build/weather_cli - Windows:
build\weather_cli.exe
- macOS/Linux:
- Verify the launch configuration in .vscode/launch.json
copilot-cpp/
├── .vscode/ 📁 VS Code configuration
│ ├── c_cpp_properties.json # IntelliSense config
│ ├── settings.json # Workspace settings
│ ├── tasks.json # Build tasks
│ ├── launch.json # Debug configurations
│ └── extensions.json # Recommended extensions
├── include/ 📁 Header files
├── src/ 📁 Source files
├── tests/ 📁 Test files
└── CMakeLists.txt 📄 Build configuration
- Access via `Ctrl+``
- Automatically uses correct environment
Add to settings:
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000- Pre-configured in .vscode/tasks.json
- Access via
Cmd+Shift+P→ "Tasks: Run Task"
- Source Control panel (
Ctrl+Shift+G) - Stage, commit, and push from UI
- Ask questions via Copilot Chat (
Cmd+I/Ctrl+I) - Get code suggestions as you type
- Follow project instructions in
.github/copilot-instructions.md
On macOS/Linux:
make buildOn Windows:
mingw32-make buildVS Code automatically uses the correct CMake configuration based on your OS.
Settings in .vscode/settings.json adapt automatically:
- Compiler paths
- Include directories
- Build configurations
Find all usages:
- Right-click on symbol
- Select "Find All References"
Go to definition:
- Click while holding
Cmd(macOS) orCtrl(Windows/Linux) - Or press
F12
- Press
Alt+F12to peek without leaving current file
- Select symbol
- Press
F2 - Enter new name
- All references updated automatically
- Click 💡 lightbulb icon
- Or press
Cmd+./Ctrl+. - Quick fixes and refactorings
- Build the project: Press
Cmd+Shift+B - Run tests: Open Test Explorer and click
▶️ - Debug application: Press
F5 - Explore code: Use
Cmd+Pto jump to files - Ask Copilot: Use Copilot Chat for coding help
For project-specific questions:
- See README.md
- See WINDOWS_GETTING_STARTED.md for Windows setup and troubleshooting
For VS Code issues:
- Check VS Code C++ FAQ
- Open issue on GitHub