Catalog / VS Code Cheatsheet

VS Code Cheatsheet

A comprehensive cheat sheet for Visual Studio Code, covering essential keyboard shortcuts, commands, and configurations to boost productivity.

Basic Navigation & Editing

Core Shortcuts

Ctrl+Shift+P or F1

Show Command Palette

Ctrl+P

Quick Open, Go to File…

Ctrl+Shift+N

New VS Code instance

Ctrl+S

Save

Ctrl+Shift+S

Save As…

Ctrl+X

Cut line (empty selection)

Ctrl+C

Copy line (empty selection)

Alt+Up/Down

Move line up/down

Multi-Cursor & Selection

Alt+Click

Insert cursor

Ctrl+Alt+Up/Down

Insert cursor above/below

Ctrl+D

Select next occurrence

Ctrl+K Ctrl+D

Skip current occurrence

Shift+Alt+I

Insert cursor at end of each line selected

Ctrl+Shift+L

Select all occurrences of current selection

Basic Editing Actions

Ctrl+Z

Undo

Ctrl+Y or Ctrl+Shift+Z

Redo

Ctrl+[/]

Comment/uncomment line

Shift+Alt+A

Block comment

Ctrl+K Ctrl+0

Fold region

Ctrl+K Ctrl+J

Unfold region

Search & Replace

Find and Replace Shortcuts

Ctrl+F

Find

Ctrl+H

Replace

F3 / Shift+F3

Find next/previous

Alt+Enter

Select all occurrences of Find match

Advanced Search

Use the Find widget (Ctrl+F) or Search view (Ctrl+Shift+F) for advanced search options. Supports regular expressions, case sensitivity, and whole word matching.

Modify settings to exclude certain files or folders from the search using files.exclude and search.exclude in settings.json.

Replace Functionality

The Replace feature (Ctrl+H) allows you to replace single or all occurrences of the found text. You can use regular expressions for more complex replacements.

Use the Replace All button cautiously, especially when using regular expressions, to avoid unintended changes.

Code Formatting & Refactoring

Code Formatting

Shift+Alt+F

Format Document

Ctrl+K Ctrl+F

Format Selection

editor.formatOnSave

Format on Save (setting in settings.json)

Refactoring

F2

Rename Symbol

Ctrl+Shift+R

Trigger Refactor

Organize Imports

Install extensions like ‘Python’ or ‘ESLint’ to enable advanced features such as organize imports and automatic code cleanup.

Use specific language features (e.g., in Python, use Ctrl+Shift+P then ‘Organize Imports’) to sort and clean up your imports.

Debugging

Debugging Basics

F9

Toggle breakpoint

F5

Start/Continue debugging

Shift+F5

Stop debugging

F10

Step over

F11

Step into

Shift+F11

Step out

Debugging Configuration

Create a launch.json file in the .vscode folder of your project to configure debugging settings for different environments and languages. This allows you to specify the program to run, arguments, and other debugging options.

Customize breakpoints by adding conditions, hit counts, and log messages to make debugging more efficient.

Useful Debugging Features

Use the Debug Console to evaluate expressions, inspect variables, and execute commands during a debugging session.

Utilize the Watch window to monitor specific variables or expressions as your code executes.