VS Code Guide

A comprehensive guide to Visual Studio Code โ€” shortcuts, extensions, debugging, Git integration, multi-cursor, Emmet, remote development, and more. Every code block has a Copy button.

Copy button on each code block  ยท  โ— Beginner โ— Intermediate โ— Advanced

01 Introduction โ€” What is VS Code?

Visual Studio Code (VS Code) is a free, open-source code editor developed by Microsoft. It runs on Windows, macOS, and Linux, and supports hundreds of programming languages out of the box. With its rich extension ecosystem, integrated terminal, debugger, and Git support, VS Code has become the most popular developer editor worldwide.

Key features include:

Analogy: VS Code is like a Swiss Army knife for developers โ€” lightweight by default, but infinitely expandable through extensions. It replaces the need for multiple separate tools (editor, terminal, debugger, Git client).

02 Installation & First Launch Beginner

Download & Install

Launch from Terminal

# Open VS Code in the current directory
code .

# Open a specific file
code index.js

# Open and wait for the window to close (useful for Git commit messages)
code --wait file.txt

# Open without a window (add to PATH during install on Windows/macOS)
code --help
๐Ÿ’ก Tip: On macOS, after installing, open the Command Palette (Cmd+Shift+P), type Shell Command: Install 'code' command in PATH, and run it to enable the code terminal command.

First Launch Checklist

03 Interface Overview Beginner

VS Code's interface is divided into five main areas:

Activity Bar
Far left โ€” switch between Explorer, Search, Source Control, Run, Extensions
Side Bar
Shows content for the selected activity (file tree, search results, etc.)
Editor
Central area โ€” open and edit files in tabs
Panel
Bottom โ€” terminal, output, debug console, problems
Status Bar
Bottom edge โ€” branch, encoding, line/col, language mode, errors

Common View Commands

# Toggle Sidebar visibility
Ctrl+B

# Toggle Panel visibility
Ctrl+J

# Toggle Sidebar orientation (left/right)
# Context menu on Activity Bar โ†’ Move Sidebar Right/Left

# Zen Mode โ€” full-screen, distraction-free editing
Ctrl+K Z

# Toggle Minimap (code overview on the right edge)
Ctrl+Shift+P โ†’ "View: Toggle Minimap"

# Split editor vertically
Ctrl+\
๐Ÿ’ก Tip: Use Zen Mode (Ctrl+K Z) when you need to focus. Press Esc Esc to exit.

04 Essential Keyboard Shortcuts Beginner

These shortcuts will save you the most time. Windows/Linux keys shown; macOS users replace Ctrl with Cmd and Alt with Option.

Ctrl+P
Quick Open โ€” fuzzy-find any file
Ctrl+Shift+P
Command Palette
Ctrl+`
Toggle Integrated Terminal
Ctrl+Shift+N
New window
Ctrl+W
Close current tab
Ctrl+Tab
Cycle through open tabs
Ctrl+B
Toggle Sidebar
Ctrl+J
Toggle Panel
Ctrl+D
Select word โ€” press again to multi-select next match
Ctrl+Shift+L
Select all occurrences of current word
Ctrl+/
Toggle line comment
Ctrl+Shift+A
Toggle block comment
Alt+โ†‘/โ†“
Move line up/down
Alt+Shift+โ†‘/โ†“
Copy line up/down
Ctrl+Shift+K
Delete entire line
Ctrl+Shift+Enter
Insert line above current

05 Command Palette Beginner

The Command Palette is the single most important feature in VS Code. Press Ctrl+Shift+P and start typing to access almost every command in the editor.

Common Palette Commands

# Toggle settings
> Preferences: Open Settings (UI)

# Install extensions
> Extensions: Install Extensions

# Change color theme
> Preferences: Color Theme

# Change file icon theme
> Preferences: File Icon Theme

# Open keyboard shortcuts
> Preferences: Open Keyboard Shortcuts

# Format document
> Format Document

# Toggle line numbers
> View: Toggle Line Numbers

# Reopen closed tab
> Workbench: Reopen Closed Editor
๐Ÿ’ก Tip: Type ? in the palette to see available special prefixes: > for commands, @ for symbols, : for line numbers, and # for file names.

Quick Open (Ctrl+P)

Press Ctrl+P and type part of a filename to navigate instantly. Add modifiers:

06 Integrated Terminal Beginner

The integrated terminal gives you a full shell inside VS Code. Open it with Ctrl+` (backtick).

Terminal Management

# Open a new terminal instance
Ctrl+Shift+`

# Switch between terminals
Ctrl+PageUp / Ctrl+PageDown

# Open terminal in a specific folder
# Click + dropdown โ†’ Select Default Profile โ†’ Choose folder

# Create a split terminal (side by side)
# Right-click terminal tab โ†’ Split, or Ctrl+Shift+5

# Clear terminal
# Type 'clear' in the terminal or click trash icon

# Open file links in terminal output
# Ctrl+Click on a file:line in terminal output

Default Shell

You can change the default shell via the Command Palette: Terminal: Select Default Profile. Options include:

Pro tip: You can open a terminal directly at a project root by right-clicking a folder in the Explorer and selecting Open in Integrated Terminal.

07 Extensions Beginner

Extensions are what make VS Code infinitely customizable. Open the Extensions panel with Ctrl+Shift+X.

Essential Extensions

Prettier
Code formatter for JS/TS, CSS, HTML, JSON, Markdown
ESLint
JavaScript/TypeScript linting
GitLens
Supercharges Git โ€” blame, history, code lens
Live Share
Real-time collaborative editing
Thunder Client
Lightweight REST API client
vscode-icons
File-specific icons in the explorer
Error Lens
Inline error/warning display
Path Intellisense
Auto-completes file paths
Remote โ€” SSH
Develop on remote machines via SSH
Docker
Manage containers, images, compose files

Extension Management Commands

# Open Extensions panel
Ctrl+Shift+X

# Install from command line
code --install-extension esbenp.prettier-vscode

# List installed extensions
code --list-extensions

# Disable all extensions (troubleshooting)
code --disable-extensions
๐Ÿ’ก Tip: Search extensions by @category:"formatters" or @recommended in the Extensions panel to find curated lists.

08 Settings & Customization Intermediate

VS Code settings are stored in settings.json. You can edit them via the UI (Ctrl+,) or directly in JSON.

Open Settings

# Open Settings UI
Ctrl+,

# Open settings.json directly
Ctrl+Shift+P โ†’ "Preferences: Open Settings (JSON)"

# Open workspace settings (project-specific)
# .vscode/settings.json in your project root

Popular Settings

{
  // Editor appearance
  "editor.fontSize": 14,
  "editor.fontFamily": "'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace",
  "editor.fontLigatures": true,
  "editor.lineHeight": 24,
  "editor.minimap.enabled": true,
  "editor.renderWhitespace": "boundary",
  "editor.bracketPairColorization.enabled": true,

  // Format on save
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",

  // Word wrap
  "editor.wordWrap": "on",

  // Auto save
  "files.autoSave": "onFocusChange",

  // Tab size
  "editor.tabSize": 2,
  "editor.insertSpaces": true,

  // Explorer
  "explorer.compactFolders": false,
  "explorer.confirmDragAndDrop": false,

  // Terminal
  "terminal.integrated.fontSize": 13,
  "terminal.integrated.defaultProfile.linux": "bash",

  // Git
  "git.enableSmartCommit": true,
  "git.autofetch": true
}

Settings Layers

โš  Workspace settings override user settings. This is useful for project-specific formatting rules.

09 Snippets Intermediate

Snippets let you insert repetitive code blocks quickly by typing a prefix and pressing Tab.

Built-in Snippets

VS Code comes with built-in snippets for many languages. For example, in JavaScript/TypeScript:

// Type 'log' and press Tab
console.log();

// Type 'fn' in JS/TS
function name() {

}

// Type 'for' โ†’ for loop
for (let index = 0; index < array.length; index++) {
  const element = array[index];
}

// Type 'clg' in JS
console.log()

Create Your Own Snippets

// Open: Command Palette โ†’ Preferences: Configure User Snippets
// Choose a language or create a global one

{
  // Example: React functional component snippet
  "React Functional Component": {
    "prefix": "rfc",
    "body": [
      "import React from 'react';",
      "",
      "const ${1:ComponentName} = () => {",
      "  return (",
      "    <div>$0</div>",
      "  );",
      "};",
      "",
      "export default ${1:ComponentName};"
    ],
    "description": "React Functional Component"
  }
}
๐Ÿ’ก Tip: $1, $2 are tab stops. $0 is the final cursor position. ${1:default} creates a placeholder with default text. Wrap in ${1|a,b|} for a choice list.

10 Debugging Intermediate

VS Code has a built-in debugger that supports Node.js, Python, Java, C++, and more via extensions.

Getting Started

# Open Run and Debug panel
Ctrl+Shift+D

# Start debugging (F5)
F5

# Toggle breakpoint (click gutter or F9)
F9

# Step over
F10

# Step into
F11

# Step out
Shift+F11

# Continue (resume execution)
F5

# Stop debugging
Shift+F5

# Restart debugging
Ctrl+Shift+F5

Launch Configuration

Create a .vscode/launch.json file. Here's an example for Node.js:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "skipFiles": ["<node_internals>/**"],
      "program": "${workspaceFolder}/index.js"
    },
    {
      "type": "node",
      "request": "attach",
      "name": "Attach to Process",
      "port": 9229
    }
  ]
}
Variable reference: ${workspaceFolder} โ€” current project root, ${file} โ€” currently open file, ${lineNumber} โ€” current line, ${env:VAR} โ€” environment variable.

Debug Features

11 Git Integration Intermediate

VS Code has deep Git integration built in. Open the Source Control panel with Ctrl+Shift+G.

Common Git Actions

# Open Source Control panel
Ctrl+Shift+G

# Stage file changes (click + next to file)
# Stage all: hover "Changes" โ†’ click +

# Commit staged changes
# Type message in input box โ†’ Ctrl+Enter

# Pull latest
# Click ... โ†’ Pull, or run in terminal

# Push commits
# Click ... โ†’ Push, or run in terminal

# View git history for a file
# Right-click in editor โ†’ Git: View History

# Open diff view
# Click a modified file in Source Control panel

# Discard changes
# Right-click file โ†’ Discard Changes

GitLens (Recommended Extension)

GitLens supercharges the Git experience by adding:

๐Ÿ’ก Tip: Enable "git.enableSmartCommit": true in settings to stage all changes when you type a commit message, skipping the staging step.

12 Multiple Cursors & Selection Intermediate

Multi-cursor editing lets you make the same edit in multiple places simultaneously โ€” one of VS Code's most powerful features.

Multi-Cursor Techniques

# Add cursor at next occurrence of selection
Ctrl+D

# Add cursor at every occurrence of selection
Ctrl+Shift+L

# Add cursor above/below
Ctrl+Alt+โ†‘ / Ctrl+Alt+โ†“

# Add cursor at arbitrary locations
# Alt+Click to add a cursor wherever you click

# Undo last cursor action
Ctrl+U

# Select all occurrences of current word
Ctrl+Shift+L

# Cancel multi-cursor
Esc

Practical Workflows

13 Find & Replace Beginner

In the Current File

# Find
Ctrl+F

# Find and replace
Ctrl+H

# Toggle case sensitivity  (Aa button)
Alt+C

# Toggle whole word match  (Ab button)
Alt+W

# Toggle regex mode  (.* button)
Alt+R

# Find next / previous
Enter / Shift+Enter

# Close find widget
Esc

Across All Files (Search)

# Open Search (global find)
Ctrl+Shift+F

# Search and replace across files
Ctrl+Shift+H

# Include/exclude files (use glob patterns)
# In the "files to include" box: src/**/*.js
# In the "files to exclude" box: node_modules, dist

# Toggle search details
# Click the ellipsis (...) in the Search panel

# Preview search results inline
# Results show a snippet of matching lines

Useful Regex Patterns

^
Start of a line
$
End of a line
\s+
One or more whitespace characters
\d+
One or more digits
(foo|bar)
Match foo OR bar
$1, $2
Backreferences in replace

14 Emmet Intermediate

Emmet lets you write HTML and CSS at lightning speed using CSS-like abbreviations. Built into VS Code for HTML, CSS, JSX, and more.

HTML Abbreviations

// Type and press Tab

// Basic structure
!             โ†’ <!DOCTYPE html>... (full HTML5 boilerplate)

// Elements
div           โ†’ <div></div>
p             โ†’ <p></p>
a             โ†’ <a href=""></a>
img           โ†’ <img src="" alt="" />

// Nesting
nav>ul>li   โ†’ <nav><ul><li></li></ul></nav>

// Siblings
div+p+bq     โ†’ <div></div><p></p><blockquote></blockquote>

// Multiplication
ul>li*5      โ†’ <ul><li>*5</li></ul>

// IDs and classes
div#header   โ†’ <div id="header"></div>
div.container โ†’ <div class="container"></div>

// Attributes
a[href="https://example.com"] โ†’ <a href="https://example.com"></a>

// Text
p{Hello}     โ†’ <p>Hello</p>

// Numbered items
ul>li.item$*3 โ†’ <ul><li class="item1"></li>...</ul>

CSS Abbreviations

// Properties
m            โ†’ margin: ;
p            โ†’ padding: ;
c            โ†’ color: #000;
bg           โ†’ background: #000;
bgc          โ†’ background-color: #000;
ff           โ†’ font-family: ;
fs           โ†’ font-size: ;
fw           โ†’ font-weight: ;
ta:c         โ†’ text-align: center;
d:f          โ†’ display: flex;
jc:c         โ†’ justify-content: center;
ai:c         โ†’ align-items: center;
bdrs         โ†’ border-radius: ;

// Vendor prefixes
// Many are handled automatically
๐Ÿ’ก Tip: Emmet works in JSX too. Open the Command Palette and search Emmet: Wrap with Abbreviation to wrap existing code with an Emmet expression.

15 Tasks & Build Systems Advanced

Tasks let you run tools like build scripts, linters, test runners, or any shell command directly from VS Code.

Create a Task

Create a .vscode/tasks.json file:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Build Project",
      "type": "shell",
      "command": "npm run build",
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "problemMatcher": ["$tsc"]
    },
    {
      "label": "Run Tests",
      "type": "shell",
      "command": "npm test",
      "group": "test"
    },
    {
      "label": "Lint",
      "type": "shell",
      "command": "npm run lint"
    }
  ]
}

Run a Task

Problem Matchers

Problem matchers parse compiler/linter output and highlight issues inline. Built-in matchers include:

Tip: You can define custom problem matchers using regex patterns in tasks.json problemMatcher object.

16 Remote Development Advanced

With the Remote Development extension pack, VS Code can open folders on remote machines, containers, or WSL as if they were local.

Remote Options

Remote โ€” SSH
Connect to any machine via SSH. Full dev experience with port forwarding.
Dev Containers
Develop inside Docker containers with full toolchain isolation.
Remote โ€” WSL
Open Linux projects in WSL with native Windows VS Code UI.
Remote โ€” Tunnels
Expose your local VS Code securely over the internet.

Quick Start: SSH Remote

# Install "Remote โ€” SSH" extension
# Open Command Palette โ†’ Remote-SSH: Connect to Host

# Or open from terminal
code --remote ssh-remote+dev.example.com /path/to/project

# Add SSH hosts to your config (~/.ssh/config)
Host dev-server
  HostName 192.168.1.100
  User ubuntu
  IdentityFile ~/.ssh/id_ed25519

Quick Start: Dev Containers

# Create .devcontainer/devcontainer.json in your project
{
  "name": "Node.js Dev",
  "image": "mcr.microsoft.com/devcontainers/javascript-node:18",
  "forwardPorts": [3000],
  "extensions": ["dbaeumer.vscode-eslint"],
  "postCreateCommand": "npm install"
}

# Open Command Palette
# โ†’ Dev Containers: Reopen in Container
โš  Remote Development requires the Remote Development extension pack from Microsoft. Dev Containers need Docker installed on the host.

17 Keyboard Shortcuts Reference Beginner

Windows/Linux keys shown. macOS: replace Ctrl โ†’ Cmd, Alt โ†’ Option.

General

Ctrl+Shift+P
Command Palette
Ctrl+P
Quick Open file
Ctrl+Shift+N
New window
Ctrl+W
Close tab
Ctrl+,
Open Settings
Ctrl+K Ctrl+S
Keyboard Shortcuts

Editing

Ctrl+X
Cut line (empty selection)
Ctrl+C
Copy line (empty selection)
Alt+โ†‘/โ†“
Move line
Alt+Shift+โ†‘/โ†“
Copy line
Ctrl+Shift+K
Delete line
Ctrl+Enter
Insert line below
Ctrl+Shift+Enter
Insert line above
Ctrl+D
Select word / next occurrence
Ctrl+Shift+L
Select all occurrences
Ctrl+Alt+โ†‘/โ†“
Multi-cursor above/below
Ctrl+U
Undo last cursor

Navigation

Ctrl+G
Go to line
Ctrl+P + @
Go to symbol in file
Ctrl+T
Go to symbol in workspace
F12
Go to definition
Alt+F12
Peek definition
Shift+F12
Find all references
Ctrl+Shift+O
Go to symbol
Ctrl+Tab
Navigate editor groups

Search & Replace

Ctrl+F
Find
Ctrl+H
Find & Replace
F3
Find next
Shift+F3
Find previous
Ctrl+Shift+F
Search across files
Ctrl+Shift+H
Replace across files

Debugging

F5
Start / Continue
F9
Toggle breakpoint
F10
Step over
F11
Step into
Shift+F11
Step out
Ctrl+Shift+F5
Restart
Shift+F5
Stop
Ctrl+Shift+D
Open Run panel

Terminal & Panel

Ctrl+`
Toggle terminal
Ctrl+J
Toggle panel
Ctrl+B
Toggle sidebar
Ctrl+Shift+`
New terminal
Ctrl+K
Clear terminal
Ctrl+Shift+5
Split terminal