⏳
Loading cheatsheet...
Setup, Navigation, Editing Power, Extensions, Debugging, Customization, Remote Development — VS Code mastery.
# ── macOS ──
brew install --cask visual-studio-code
# ── Ubuntu/Debian ──
sudo apt update
sudo apt install wget gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null
sudo apt update && sudo apt install code
# ── Fedora/RHEL ──
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo dnf install code
# ── Windows ──
# Download from https://code.visualstudio.com/
# Or via winget:
winget install Microsoft.VisualStudioCode
# ── Verify Installation ──
code --version# ── Open Files/Directories ──
code # launch VS Code
code . # open current directory
code file.ts # open a specific file
code file1.ts file2.ts # open multiple files
code -r . # open in last active window
code -n . # open in new window
code -g # open VS Code Insiders
# ── Diff Files ──
code --diff file1.ts file2.ts
# ── Pipe to VS Code ──
echo "hello" | code - # read from stdin
# ── Install Extensions from CLI ──
code --install-extension dbaeumer.vscode-eslint
code --uninstall-extension extension-id
code --list-extensions| Edition | License | Key Features |
|---|---|---|
| VS Code (Stable) | MIT / Proprietary marketplace | Microsoft marketplace, telemetry, remote |
| VS Code Insiders | MIT / Proprietary marketplace | Early features, nightly builds |
| VSCodium | MIT | Open source, no telemetry, open-vsx marketplace |
| Code - OSS | MIT | Upstream repo, no marketplace access |
| OS | Settings Path |
|---|---|
| macOS | ~/Library/Application Support/Code/User/ |
| Linux | ~/.config/Code/User/ |
| Windows | %APPDATA%\Code\User\ |
| Portable | data/user-data/User/ |
| Shortcut | Action | Use Case |
|---|---|---|
| Alt+Click | Add cursor | Click anywhere to add cursor |
| Ctrl+Alt+Up/Down | Add cursors above/below | Vertical multi-edit |
| Ctrl+D | Select next occurrence | Rename variables quickly |
| Ctrl+Shift+D | Undo last cursor | Remove last added cursor |
| Ctrl+Shift+L | Select all occurrences | Bulk rename all matches |
| Ctrl+U | Undo cursor | Remove last cursor from stack |
| Ctrl+L | Select current line | Entire line selection |
| Shift+Alt+Drag | Column (block) selection | Edit vertical columns |
| Shift+Alt+I | Insert cursor at line ends | Add text to end of all lines |
| Shortcut | Action |
|---|---|
| Ctrl+F / Cmd+F | Find |
| Ctrl+H / Cmd+H | Find and Replace |
| Ctrl+Shift+F / Cmd+Shift+F | Find in Files |
| Ctrl+Shift+H / Cmd+Shift+H | Replace in Files |
| Alt+Enter in Find | Toggle Find in Selection |
| Click *.xx in Find | Include/Exclude file types |
| Alt+C / Alt+W / Alt+R | Toggle Case Sensitive / Whole Word / Regex |
# ── Code Folding ──
Ctrl+Shift+[ # Fold (collapse) region
Ctrl+Shift+] # Unfold (expand) region
Ctrl+K Ctrl+0 # Fold all regions
Ctrl+K Ctrl+J # Unfold all regions
Ctrl+K Ctrl+1 # Fold level 1
Ctrl+K Ctrl+2 # Fold level 2
Ctrl+K Ctrl+[ # Fold at cursor
# ── Zen Mode (Distraction Free) ──
Ctrl+K Z # Toggle Zen Mode
# Esc Esc to exit Zen ModeCtrl+D repeatedly to select matching occurrences one by one, then edit them all simultaneously. Combine with Ctrl+Shift+L to select ALL occurrences at once. This is incredibly powerful for renaming variables or fixing repeated patterns.Extensions supercharge VS Code. Install via the Extensions panel (Ctrl+Shift+X), CLI, or marketplace.
| Extension | ID | Purpose |
|---|---|---|
| ESLint | dbaeumer.vscode-eslint | JavaScript/TypeScript linting |
| Prettier | esbenp.prettier-vscode | Code formatter |
| GitLens | eamodio.gitlens | Git supercharged (blame, history) |
| Thunder Client | rangav.vscode-thunder-client | REST API testing |
| Docker | ms-azuretools.vscode-docker | Docker management |
| Python | ms-python.python | Python IntelliSense, debugging |
| Go | golang.go | Go language support |
| Rust Analyzer | rust-lang.rust-analyzer | Rust IDE support |
| Tailwind CSS IntelliSense | bradlc.vscode-tailwindcss | Tailwind class autocomplete |
| Error Lens | usernamehw.errorlens | Inline error highlighting |
| GitGraph | mhutchie.gitgraph | Visual git log |
| Live Share | ms-vsliveshare.vsliveshare | Real-time collaboration |
| Remote - SSH | ms-vscode-remote.remote-ssh | Remote development |
| Remote - Containers | ms-vscode-remote.remote-containers | Dev container support |
| Remote - WSL | ms-vscode-remote.remote-wsl | Windows WSL support |
# ── CLI Extension Commands ──
code --install-extension publisher.extensionName
code --uninstall-extension publisher.extensionName
code --list-extensions
code --list-extensions --show-versions
code --disable-extension publisher.extensionName
code --enable-extension publisher.extensionName
# ── Sync Settings ──
# Settings Sync is built-in (Sign in with GitHub/Microsoft)
# Syncs: Settings, Keyboard Shortcuts, Snippets, Extensions, UI State
# ── Install from .vsix File ──
code --install-extension my-extension.vsix{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/src/index.ts",
"preLaunchTask": "npm: build",
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"sourceMaps": true,
"smartStep": true,
"skipFiles": ["<node_internals>/**"]
},
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"port": 9229,
"restart": true,
"stopOnEntry": false
},
{
"type": "node",
"request": "launch",
"name": "Jest Tests",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["--runInBand", "--no-cache"],
"console": "integratedTerminal"
}
],
"compounds": [
{
"name": "Full Stack",
"configurations": ["Launch Server", "Launch Client"],
"preLaunchTask": "npm: build",
"stopAll": true
}
]
}| Shortcut | Action |
|---|---|
| F5 | Start / Continue debugging |
| F9 | Toggle breakpoint |
| F10 | Step Over |
| F11 | Step Into |
| Shift+F11 | Step Out |
| Shift+F5 | Stop debugging |
| Ctrl+Shift+F5 | Restart debugging |
| Ctrl+Shift+B | Toggle Build Breakpoint (conditional) |
| Ctrl+F5 | Run without debugging |
| Type | How to Set | Use Case |
|---|---|---|
| Line Breakpoint | Click gutter or F9 | Pause at a line |
| Conditional Breakpoint | Right-click gutter | Pause when expression is true |
| Logpoint | Right-click gutter | Log message without pausing |
| Hit Count | Edit breakpoint | Pause after N hits |
| Triggered Breakpoint | Edit breakpoint | Activate after other BP hits |
| Function Breakpoint | Debug panel + button | Break on function entry |
| Data Breakpoint | Variables panel right-click | Break when variable changes |
Debug: {myVar} syntax with curly braces to evaluate expressions.| Level | Location | Scope | Shared? |
|---|---|---|---|
| Default | VS Code installation | All instances | No |
| User | ~/.config/Code/User/settings.json | Your account | No |
| Workspace | .vscode/settings.json | Current project | Yes (committed) |
| Workspace Folder | .vscode/settings.json (multi-root) | Specific folder | Yes |
| Remote | On remote machine | Remote session | No |
[
{
"key": "ctrl+k ctrl+ctrl+k",
"command": "editor.action.formatDocument",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+up",
"command": "editor.action.moveLinesUpAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+d",
"command": "editor.action.copyLinesDownAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "alt+/",
"command": "editor.action.triggerSuggest",
"when": "editorTextFocus"
}
]{
"React Component": {
"prefix": "rfc",
"body": [
"import React from 'react';",
"",
"interface ${1:${TM_FILENAME_BASE}}Props {",
" ${2:// props}",
"}",
"",
"export default function ${1:${TM_FILENAME_BASE}}({${3:props}}: ${1:${TM_FILENAME_BASE}}Props) {",
" return (",
" <div>",
" ${4:// content}",
" </div>",
" );",
"}"
],
"description": "Create React Functional Component"
},
"Console Log": {
"prefix": "cl",
"body": ["console.log('${1:message}', ${2:variable});"],
"description": "Insert console.log statement"
}
}{
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "explicit"
},
"editor.suggestSelection": "first",
"editor.tabCompletion": "on",
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": true,
"editor.inlineSuggest.enabled": true,
"editor.stickyScroll.enabled": true,
"editor.linkedEditing": true,
"editor.wordWrapColumn": 120,
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000,
"explorer.confirmDelete": false,
"explorer.confirmDragAndDrop": false,
"git.autofetch": true,
"git.confirmSync": false,
"terminal.integrated.scrollback": 10000,
"workbench.startupEditor": "none"
}Settings > Turn on Settings Sync.# 1. Install Remote - SSH extension
# 2. Connect to remote:
# Ctrl+Shift+P → "Remote-SSH: Connect to Host"
# 3. Edit ~/.ssh/config:
Host my-server
HostName 192.168.1.100
User developer
IdentityFile ~/.ssh/id_ed25519
ForwardAgent yes
# 4. VS Code server installs on remote
# Extensions install on remote machine
# Local UI, remote execution{
"name": "Node.js Dev",
"image": "mcr.microsoft.com/devcontainers/typescript-node:20",
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/docker:1": {}
},
"forwardPorts": [3000, 5432],
"postCreateCommand": "npm install",
"customizations": {
"vscode": {
"extensions": ["dbaeumer.vscode-eslint"]
}
}
}Collaborate in real-time. Share your workspace, terminals, and debugging sessions.
| Action | How |
|---|---|
| Start session | Live Share: Start Session |
| Join session | Live Share: Join Session (link) |
| Read-only session | Live Share: Start Read-Only Session |
| Share server | Start session on remote server |