Why VS Code?
Imagine you're a writer. You could write your novel on napkins, in a basic notepad, or use a professional writing tool with spell-check, formatting options, and organization features. VS Code is like that professional writing tool, but for programmers!
Key Benefits
- Free and Open Source: Like a community garden where everyone can contribute
- Cross-Platform: Works on Windows, Mac, and Linux
- Lightweight yet Powerful: Fast like a sports car, but with all the features of a luxury vehicle
- Huge Extension Marketplace: Like an app store for developer tools
Installation Steps
Step 1: Download VS Code
- Visit code.visualstudio.com
- Click the download button for your operating system
- The website automatically detects your OS (Windows/Mac/Linux)
Step 2: Installation Process
Windows Installation
- Run the downloaded .exe file
- Accept the license agreement
- Choose installation location (default is fine)
- Select additional tasks:
- ✓ Add "Open with Code" to context menu
- ✓ Add to PATH (important!)
- ✓ Register Code as default editor for supported files
- Click Install
- Launch VS Code when installation completes
Mac Installation
- Open the downloaded .dmg file
- Drag Visual Studio Code to Applications folder
- Launch VS Code from Applications
- When prompted, allow VS Code to access folders
- To add to PATH: Open Command Palette (Cmd+Shift+P) and type "shell command"
- Select "Install 'code' command in PATH"
Linux Installation (Ubuntu/Debian)
- Download the .deb package
- Open terminal and navigate to downloads
- Run:
sudo dpkg -i <file>.deb - If dependencies error occurs:
sudo apt-get install -f - Launch with:
code
First Launch: Getting Familiar
When you first open VS Code, it's like walking into a new workshop. Let's explore the layout:
Key Interface Elements
- Activity Bar (Left): Your main navigation - like app shortcuts on your phone
Side Bar: Contextual information based on selected activity - Editor Area: Where you write code - can have multiple files open in tabs
- Status Bar (Bottom): Shows current file info, Git status, and errors
- Panel: Terminal, output, problems - like a Swiss Army knife of tools
Essential Settings
Before we install extensions, let's configure some basic settings. Think of this as adjusting your car seat and mirrors before driving.
Opening Settings
- Windows/Linux: File → Preferences → Settings (or Ctrl+,)
- Mac: Code → Preferences → Settings (or Cmd+,)
Recommended Settings
{
"editor.fontSize": 14,
"editor.tabSize": 2,
"editor.wordWrap": "on",
"editor.minimap.enabled": true,
"editor.formatOnSave": true,
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000,
"workbench.startupEditor": "newUntitledFile",
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": true
}
What these settings do:
fontSize: Comfortable text size for long coding sessionstabSize: Standard for JavaScript/React developmentwordWrap: Prevents horizontal scrollingformatOnSave: Automatically formats code when savingautoSave: Never lose work with automatic savingbracketPairColorization: Color-codes matching brackets
Essential Extensions
Extensions are like power tools for your coding workshop. Let's install the essential ones:
Installing Extensions
- Click the Extensions icon in the Activity Bar (or Ctrl+Shift+X)
- Search for the extension name
- Click Install
Must-Have Extensions for Web Development
1. ESLint
Purpose: Like a spell-checker for your code
- Catches errors before you run code
- Enforces coding standards
- Suggests best practices
2. Prettier - Code Formatter
Purpose: Automatically formats your code for consistency
- Consistent indentation
- Proper spacing
- Standardized quote usage
3. Live Server
Purpose: Like having a personal web server
- Launches local development server
- Auto-refreshes browser on file changes
- Essential for frontend development
4. GitLens
Purpose: Supercharges Git capabilities
- See who changed what and when
- Inline blame annotations
- Powerful repository visualization
5. Auto Rename Tag
Purpose: Automatically renames paired HTML/XML tags
- Change opening tag, closing tag updates automatically
- Prevents mismatched tags
- Huge time-saver for HTML work
Keyboard Shortcuts
Learning keyboard shortcuts is like learning to touch-type - it seems slow at first but makes you much more productive.
Essential Shortcuts
| Action | Windows/Linux | Mac |
|---|---|---|
| Open Command Palette | Ctrl+Shift+P | Cmd+Shift+P |
| Quick Open File | Ctrl+P | Cmd+P |
| Toggle Terminal | Ctrl+` | Cmd+` |
| Save File | Ctrl+S | Cmd+S |
| Find in File | Ctrl+F | Cmd+F |
| Multiple Cursors | Alt+Click | Option+Click |
| Comment Line | Ctrl+/ | Cmd+/ |
Creating Your First Project
Let's create a simple project to test our setup:
- Create a new folder called "my-first-project"
- Open VS Code
- File → Open Folder → Select "my-first-project"
- Create a new file: Click New File icon or Ctrl+N
- Save as "index.html"
- Type the following code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My First VS Code Project</title>
</head>
<body>
<h1>Hello VS Code!</h1>
<p>I'm ready to start coding!</p>
</body>
</html>
Testing Live Server
- Right-click on index.html
- Select "Open with Live Server"
- Your default browser should open showing your page
- Try changing the text and saving - watch it update automatically!
Troubleshooting Common Issues
Extension Not Working?
- Reload VS Code: Ctrl+Shift+P → "Reload Window"
- Check extension is enabled for workspace
- Look for error messages in Output panel
Live Server Not Opening?
- Check if port 5500 is already in use
- Try changing port in Live Server settings
- Ensure you have a valid HTML file open
Can't Find Settings?
- Use Command Palette (Ctrl+Shift+P)
- Type "settings" and select "Preferences: Open Settings"
- Switch between UI and JSON views using icon in top right
Assignment: VS Code Setup
- Install VS Code on your computer
- Install all recommended extensions from this lecture
- Configure the recommended settings
- Create a test project folder with an HTML file
- Test Live Server functionality
- Practice using at least 3 keyboard shortcuts
- Take a screenshot of your VS Code setup and save it
Bonus: Explore the themes marketplace and find a color theme you like!