Complete Visual Studio Code (VS Code) Keyboard Shortcuts Guide

Visual Studio Code (VS Code) is one of the most popular code editors due to its lightweight design, extensibility, and robust feature set—keyboard shortcuts are its superpower for boosting coding efficiency.

This guide covers the most essential, frequently used shortcuts for Windows/Linux and macOS, organized by use case (basic operations, editing, navigation, etc.), plus tips for customizing shortcuts to fit your workflow.

Prerequisites

  • VS Code installed (any version, but latest stable recommended).
  • Note: Shortcuts marked with Win/Linux apply to Windows 10/11 and Linux (Ubuntu, Fedora, etc.); macOS applies to macOS Monterey/Ventura/Sonoma.
  • To view all built-in shortcuts: Press Ctrl+K Ctrl+S (Win/Linux) or Cmd+K Cmd+S (macOS) to open the Keyboard Shortcuts panel (searchable and filterable).

1. Basic Editor Operations (Foundational Shortcuts)

These shortcuts handle core editor tasks (file management, window control) and are used daily by all developers.

ActionWin/LinuxmacOS
Open VS Code Command Palette (most powerful shortcut!)Ctrl+Shift+P / F1Cmd+Shift+P / F1
New fileCtrl+NCmd+N
New windowCtrl+Shift+NCmd+Shift+N
Open file/folderCtrl+OCmd+O
Save fileCtrl+SCmd+S
Save all filesCtrl+Shift+SCmd+Shift+S
Close active tabCtrl+WCmd+W
Close all tabsCtrl+K Ctrl+WCmd+K Cmd+W
Reopen closed tabCtrl+Shift+TCmd+Shift+T
Rename active fileF2F2
Delete active fileDelete (in Explorer)Delete (in Explorer)
Reload window (fix glitches/extension issues)Ctrl+Shift+P → type “Reload Window”Cmd+Shift+P → type “Reload Window”
Zoom in/outCtrl++ / Ctrl+-Cmd++ / Cmd+-
Reset zoomCtrl+0Cmd+0

Key Notes:

  • The Command Palette (Ctrl+Shift+P/Cmd+Shift+P) is your “one-stop shop”—you can run any VS Code command (e.g., “Format Document”, “Install Extension”) without memorizing shortcuts.
  • Ctrl+K (Win/Linux) / Cmd+K (macOS) is a “prefix key”—press it, release, then press the second key (e.g., Ctrl+K Ctrl+W = close all tabs).

2. Code Editing Shortcuts (Boost Productivity)

These shortcuts streamline writing/modifying code (indentation, selection, multi-cursor, etc.).

2.1 Text Selection & Manipulation

ActionWin/LinuxmacOS
Select all textCtrl+ACmd+A
Select current lineCtrl+LCmd+L
Select word (repeat to expand)Ctrl+DCmd+D
Select all occurrences of selected wordCtrl+Shift+LCmd+Shift+L
Expand selection (to bracket/function)Shift+Alt+RightShift+Option+Right
Shrink selectionShift+Alt+LeftShift+Option+Left
Copy selected textCtrl+CCmd+C
Cut selected textCtrl+XCmd+X
Paste textCtrl+VCmd+V
Paste and match formattingCtrl+Shift+VCmd+Shift+V
UndoCtrl+ZCmd+Z
RedoCtrl+Y / Ctrl+Shift+ZCmd+Shift+Z

2.2 Multi-Cursor Editing (Game-Changer for Bulk Edits)

Multi-cursor lets you edit multiple lines/positions at once—one of VS Code’s most loved features:

ActionWin/LinuxmacOS
Add cursor belowCtrl+Alt+DownCmd+Option+Down
Add cursor aboveCtrl+Alt+UpCmd+Option+Up
Add cursor to end of each selected lineShift+Alt+IShift+Option+I
Create cursor at click position (multi-cursor)Alt+ClickOption+Click
Cancel multi-cursorEscEsc

2.3 Indentation & Line Operations

ActionWin/LinuxmacOS
Indent line rightTabTab
Indent line leftShift+TabShift+Tab
Move line upAlt+UpOption+Up
Move line downAlt+DownOption+Down
Duplicate lineShift+Alt+DownShift+Option+Down
Delete lineCtrl+Shift+KCmd+Shift+K
Comment/Uncomment lineCtrl+/Cmd+/
Comment/Uncomment blockShift+Alt+AShift+Option+A
Format document (auto-indent/cleanup)Shift+Alt+FShift+Option+F
Format selectionCtrl+K Ctrl+FCmd+K Cmd+F

3. Code Navigation Shortcuts (Jump Quickly)

These shortcuts help you navigate large codebases without clicking through files/folders:

ActionWin/LinuxmacOS
Go to file (search by filename)Ctrl+PCmd+P
Go to line numberCtrl+GCmd+G
Go to symbol (search functions/classes in file)Ctrl+Shift+OCmd+Shift+O
Go to symbol (search across workspace)Ctrl+TCmd+T
Jump to definition (of a function/class)F12F12
Peek definition (preview without jumping)Alt+F12Option+F12
Go to references (where a symbol is used)Shift+F12Shift+F12
Jump back/forward (navigation history)Alt+Left / Alt+RightOption+Left / Option+Right
Toggle sidebar (Explorer)Ctrl+BCmd+B
Show outline (document structure)Ctrl+Shift+E (Explorer) → click “Outline”Cmd+Shift+E → click “Outline”

Pro Tip:

In Ctrl+P (Go to File), type > to open the Command Palette, : to go to a line number, or @ to go to a symbol—all from the same shortcut!


4. Window & Panel Management (Organize Your Workspace)

VS Code lets you split the editor into multiple panes and manage panels (terminal, debug, extensions) with shortcuts:

ActionWin/LinuxmacOS
Split editor verticallyCtrl+\\\\Cmd+\\\\
Split editor horizontallyCtrl+Shift+\\\\ (customize if needed)Cmd+Shift+\\\\ (customize if needed)
Switch between editor groupsCtrl+1/Ctrl+2/Ctrl+3Cmd+1/Cmd+2/Cmd+3
Move active editor to groupCtrl+K Ctrl+1 (move to group 1)Cmd+K Cmd+1
Toggle terminal panel`Ctrl+“ (backtick)`Cmd+“
New terminalCtrl+Shift+Cmd+Shift+
Toggle problems panel (errors/warnings)Ctrl+Shift+MCmd+Shift+M
Toggle extensions panelCtrl+Shift+XCmd+Shift+X
Toggle debug panelCtrl+Shift+DCmd+Shift+D
Toggle output panelCtrl+Shift+UCmd+Shift+U

5. Search & Replace Shortcuts

ActionWin/LinuxmacOS
Find in fileCtrl+FCmd+F
Replace in fileCtrl+HCmd+H
Find across workspaceCtrl+Shift+FCmd+Shift+F
Replace across workspaceCtrl+Shift+HCmd+Shift+H
Find next/previousEnter / Shift+EnterEnter / Shift+Enter
Toggle case sensitivity (find)Alt+COption+C
Toggle regex (find/replace)Alt+ROption+R
Toggle whole word (find)Alt+WOption+W

6. Version Control (Git) Shortcuts

VS Code has built-in Git integration—these shortcuts avoid switching to the terminal for common Git tasks:

ActionWin/LinuxmacOS
Open source control panelCtrl+Shift+GCmd+Shift+G
Stage selected fileCtrl+Alt+S (customize or use palette)Cmd+Option+S
Commit changesCtrl+Enter (in source control panel)Cmd+Enter
Pull changesCtrl+Shift+P → “Git: Pull”Cmd+Shift+P → “Git: Pull”
Push changesCtrl+Shift+P → “Git: Push”Cmd+Shift+P → “Git: Push”
Checkout branchCtrl+Shift+P → “Git: Checkout to”Cmd+Shift+P → “Git: Checkout to”
Compare changes (diff)Click file in source control → F7Click file → F7

7. Debugging Shortcuts

For developers debugging code (JavaScript, Python, etc.):

See also: Mastering the Linux Command Line — Your Complete Free Training Guide

ActionWin/LinuxmacOS
Start/continue debuggingF5F5
Stop debuggingShift+F5Shift+F5
Step over (next line, no into functions)F10F10
Step into (enter function)F11F11
Step out (exit function)Shift+F11Shift+F11
Toggle breakpointF9F9
Inspect hover (variable value)Hover over variable + CtrlHover over variable + Cmd
Open debug consoleCtrl+Shift+YCmd+Shift+Y

8. Customize Shortcuts (Tailor to Your Workflow)

If default shortcuts don’t fit your habits (e.g., you’re used to Sublime Text/IntelliJ), customize them:

Step 1: Open Keyboard Shortcuts Settings

  • Press Ctrl+K Ctrl+S (Win/Linux) or Cmd+K Cmd+S to open the Keyboard Shortcuts panel.
  • Alternatively: Click the gear icon → Keyboard Shortcuts.

Step 2: Customize a Shortcut

  1. Search for the command (e.g., “Format Document”).
  2. Hover over the command → click the pencil icon → press your desired key combination (e.g., Ctrl+Alt+F).
  3. Save (VS Code auto-saves to keybindings.json).

Step 3: Reset Shortcuts

  • To reset a single shortcut: Hover → click the trash can icon.
  • To reset all: Click the three dots → Reset All Keybindings.

Bonus: Import Shortcut Profiles

VS Code supports importing shortcut profiles for other editors (e.g., Sublime Text, Vim):

  1. Open the Command Palette (Ctrl+Shift+P).
  2. Type “Preferences: Open Keyboard Shortcuts (JSON)”.
  3. Install an extension like Keybinding Manager or use built-in profiles (search “keyboard shortcuts” in Extensions).

9. Must-Know Bonus Tips

  1. Vim Mode: For Vim users, install the Vim extension to enable Vim keybindings (e.g., i to insert, esc to exit, dd to delete a line).
  2. Code Snippets: Use Ctrl+Shift+P → “Insert Snippet” to insert pre-defined code snippets (e.g., for loops, function templates).
  3. Macro Recording: Record a sequence of actions (e.g., formatting + saving) with Ctrl+K Ctrl+R (Win/Linux) / Cmd+K Cmd+R, then play it back with Ctrl+K Ctrl+P / Cmd+K Cmd+P.

Summary

  1. Core Shortcuts to Memorize: Ctrl+Shift+P (Command Palette), Ctrl+P (Go to File), Ctrl+D (Multi-select), F12 (Go to Definition), and Shift+Alt+F (Format Document) are the most impactful for daily use.
  2. System Compatibility: Always check Win/Linux vs. macOS shortcuts (replace Ctrl with Cmd and Alt with Option for macOS).
  3. Customization is Key: Tailor shortcuts to your workflow (e.g., import Vim/Sublime profiles) to maximize efficiency—don’t force yourself to use default shortcuts if they feel awkward.

By mastering these shortcuts, you’ll reduce mouse usage, cut down on repetitive tasks, and write/navigate code far faster. Start with 5-10 core shortcuts, then add more as you get comfortable!

David Cao
David Cao

David is a Cloud & DevOps Enthusiast. He has years of experience as a Linux engineer. He had working experience in AMD, EMC. He likes Linux, Python, bash, and more. He is a technical blogger and a Software Engineer. He enjoys sharing his learning and contributing to open-source.

Articles: 585

Leave a Reply

Your email address will not be published. Required fields are marked *