VS Code Keyboard Shortcuts

A practical, fast-lookup cheatsheet for Visual Studio Code across macOS, Windows, and Linux. Covers how to run code (F5 vs Ctrl+F5 vs Code Runner vs REPL), smart editing, multi-cursor, unindent / reverse tab, bracket selection, collapse methods, debugging, and keymap customization.

VS Code Keyboard Shortcuts banner

How to Run Code in VS Code

What is the VS Code run shortcut? It depends on how your project is configured and whether you run with the native debugger, a task runner, or a language extension: • Built-in Debugger (F5): Compiles and launches active debug configuration, stopping at breakpoints. • Run Without Debugging (Ctrl + F5): Runs your code immediately at full speed without halting at breakpoints. • Code Runner Extension (Ctrl + Alt + N): Runs the active file or selected text directly and prints output to the Output panel. (Stop run: Ctrl + Alt + M). Note: Requires the "Code Runner" extension by Jun Han. • Language REPL / Terminal (Shift + Enter): In Python, R, and Julia extensions, sends the current line or selected code to the interactive REPL terminal. • Run Selected Lines: Highlight the target lines, then press Ctrl + Alt + N (Code Runner) or Shift + Enter (interactive terminal). • Why does Ctrl + Enter do nothing? In vanilla VS Code, Ctrl + Enter (or Cmd + Enter on Mac) inserts a blank line below the current cursor, or commits staged Git changes if focus is in the Source Control box. It does not run scripts unless you configure a custom keybinding or work inside a notebook.
Action / CommandmacOSWindows / LinuxType & What it does
Start DebuggingF5F5Built-in: Launches active configuration with full breakpoints and debug tools.
Run Without DebuggingCtrl + F5Ctrl + F5Built-in: Executes active file immediately at full speed without stopping at breakpoints.
Stop Debugging / ExecutionShift + F5Shift + F5Built-in: Terminates the running debug session or process.
Restart ExecutionCmd + Shift + F5Ctrl + Shift + F5Built-in: Restarts active launch target from the beginning.
Run Code (Active File)Ctrl + Option + NCtrl + Alt + NCode Runner Extension: Runs active file through language runner to Output tab.
Run Selected LinesCtrl + Option + NCtrl + Alt + NCode Runner Extension: Highlight code lines first, then press to execute selection.
Stop Code RunCtrl + Option + MCtrl + Alt + MCode Runner Extension: Stops the currently running code process.
Run Selection in Terminal (REPL)Shift + EnterShift + EnterLanguage Extension (Python/R/Julia): Sends highlighted code or current line to terminal.
Toggle BreakpointF9F9Built-in: Toggles a breakpoint on the current line.

Open Keyboard Shortcuts & Keybindings Editor

You can view, search, and remap every command in VS Code via the visual preferences editor or the JSON config file:
Command / ActionmacOSWindows / LinuxWhat it does
Command PaletteCmd + Shift + PCtrl + Shift + PUniversal command palette: access every command, setting, and extension action.
Open Keyboard Shortcuts (UI)Cmd + K, Cmd + SCtrl + K, Ctrl + SVisual shortcut editor: search, rebind, or clear conflicting key combinations.
Open Keyboard Shortcuts (JSON)Via Command PaletteVia Command PaletteOpens keybindings.json directly for advanced key bindings and 'when' clauses.
Open Keymap ExtensionsCmd + K, Cmd + MCtrl + K, Ctrl + MSearches marketplace for IntelliJ, Sublime, Eclipse, or Vim keymaps.

Core Navigation & Window Management

Navigation ActionmacOSWindows / LinuxWhat it does
Quick Open (Files)Cmd + PCtrl + PInstant fuzzy file finder: type filename or path to jump directly.
Command PaletteCmd + Shift + PCtrl + Shift + PSearch and execute any editor or extension command.
Go to Symbol in FileCmd + Shift + OCtrl + Shift + OJumps to methods, functions, classes, and variables in the active file.
Go to Symbol in WorkspaceCmd + TCtrl + TSearches symbols across all files in the current workspace.
Go to Line NumberCtrl + GCtrl + GDirectly jumps to a specific line (e.g. :120).
Next / Previous Editor TabCtrl + Tab / Ctrl + Shift + TabCtrl + Tab / Ctrl + Shift + TabCycles forward and backward through open editor tabs.
Toggle Primary SidebarCmd + BCtrl + BShows or hides the file explorer / extensions sidebar.
Toggle Bottom Panel (Terminal)Cmd + J (or Ctrl + `)Ctrl + J (or Ctrl + `)Shows or hides the terminal, output, problems, and debug console.
Split Editor WindowCmd + \Ctrl + \Splits active editor into two side-by-side editor panes.
Close Active Editor TabCmd + WCtrl + WCloses current editor tab (use Cmd/Ctrl + K, W to close all).

Editing, Multi-Cursor & Untab (Reverse Tab / Unindent)

How to untab / unindent in VS Code: • To unindent (reverse tab) a line or highlighted block, press Shift + Tab (or Cmd/Ctrl + [). • To indent a line or block forward, press Tab (or Cmd/Ctrl + ]). • To edit across multiple lines at once, use multi-cursor click or vertical column selection.
Editing & Multi-Cursor ActionmacOSWindows / LinuxWhat it does
Untab / Reverse Tab (Unindent)Shift + Tab (or Cmd + [)Shift + Tab (or Ctrl + [)Decreases indentation of current line or highlighted selection.
Indent Line(s)Tab (or Cmd + ])Tab (or Ctrl + ])Increases indentation of current line or highlighted selection.
Insert Extra Cursor (Click)Option + ClickAlt + ClickPlaces an independent typing cursor anywhere in the editor.
Add Cursor Above / BelowCmd + Option + Up / DownCtrl + Alt + Up / DownExtends multiple vertical typing cursors directly above or below.
Select Next OccurrenceCmd + DCtrl + DHighlights next occurrence of current word for multi-cursor editing.
Select All OccurrencesCmd + Shift + LCtrl + Shift + LHighlights all occurrences of current symbol across the entire file.
Undo Last CursorCmd + UCtrl + UCancels the most recently added cursor or selection.
Move Line Up / DownOption + Up / DownAlt + Up / DownMoves current line or selected block up or down.
Duplicate Line Up / DownShift + Option + Up / DownShift + Alt + Up / DownCopies current line or selected block directly above or below.
Delete Entire LineCmd + Shift + KCtrl + Shift + KDeletes current line without placing it in clipboard.
Toggle Line CommentCmd + /Ctrl + /Comments or uncomments current line or selected code.
Toggle Block CommentShift + Option + AShift + Alt + AWraps or unwraps selection in multi-line block comments (/* ... */).

Selection: Brackets, Matching Bracket & Column (Vertical) Select

How to use column selection and bracket matching in VS Code: • Column (box / vertical) selection via mouse: Hold Shift + Option (Mac) or Shift + Alt (Windows/Linux) while dragging your mouse over text. • Jump to matching bracket: Press Cmd/Ctrl + Shift + \ to bounce between opening and closing braces (), [], or {}. • Select code between brackets: Use Smart Select (Shift + Option/Alt + Right Arrow) to expand selection outwards from inside parentheses to enclosing brackets.
Selection CommandmacOSWindows / LinuxWhat it does
Column / Vertical Select (Mouse)Shift + Option + DragShift + Alt + DragCreates a rectangular box selection across multiple lines with mouse.
Jump to Matching BracketCmd + Shift + \Ctrl + Shift + \Jumps cursor between matching opening and closing brackets or braces.
Select Between Brackets (Expand)Shift + Option + RightShift + Alt + RightSmart Select Expand: selects token, then inner bracket scope, then outer scope.
Shrink SelectionShift + Option + LeftShift + Alt + LeftSmart Select Shrink: narrows selection back to previous smaller scope.
Add Cursors to Line EndsShift + Option + IShift + Alt + IPlaces an active cursor at the end of each selected line.
Toggle Column Selection ModeVia Command PaletteVia Command PaletteToggles default mouse selection between standard text flow and column box mode.

Folding & Collapse Methods (Minimize All Functions)

How to collapse methods and functions in VS Code: • Collapse / Fold All Methods: Press Cmd/Ctrl + K, Cmd/Ctrl + 0 to collapse every function and class across the entire file. • Unfold All Methods: Press Cmd/Ctrl + K, Cmd/Ctrl + J to expand all folded regions. • Fold by Level: Press Cmd/Ctrl + K, Cmd/Ctrl + 2 to collapse methods inside classes while keeping class headers visible.
Folding / Collapse CommandmacOSWindows / LinuxWhat it does
Collapse / Fold Current MethodCmd + Option + [Ctrl + Shift + [Folds the innermost function, method, loop, or block at cursor.
Unfold Current MethodCmd + Option + ]Ctrl + Shift + ]Expands the folded function, method, or block at cursor.
Collapse All Methods (Fold All)Cmd + K, Cmd + 0Ctrl + K, Ctrl + 0Minimizes all functions, methods, and blocks throughout the active file.
Unfold All Methods (Expand All)Cmd + K, Cmd + JCtrl + K, Ctrl + JExpands every collapsed region across the file.
Fold Methods by Level (e.g. Level 2)Cmd + K, Cmd + 2Ctrl + K, Ctrl + 2Folds all second-level blocks (ideal for collapsing class methods).
Fold All Block CommentsCmd + K, Cmd + /Ctrl + K, Ctrl + /Collapses all header docs, JSDoc, and multi-line comments.

Go to Definition, Implementation, References & Quick Fix

Action / ShortcutmacOSWindows / LinuxWhat it does
Quick Fix / Code ActionCmd + .Ctrl + .Opens Quick Fix suggestions: import missing modules, fix typing errors, apply refactorings.
Go to DefinitionF12F12Jumps directly to the source declaration of the symbol.
Peek DefinitionOption + F12Alt + F12Opens an inline popup editor displaying the definition without switching files.
Go to ImplementationCmd + F12Ctrl + F12Jumps to concrete implementation of an interface, abstract method, or trait.
Peek ImplementationCmd + Shift + F12Ctrl + Shift + F12Displays an inline preview listing all implementations across the workspace.
Find All ReferencesShift + F12Shift + F12Lists every location where the symbol is invoked across all project files.
Rename SymbolF2F2Safely renames the identifier and updates every reference across all workspace files.

Search & Replace (File & Workspace)

Search / Replace CommandmacOSWindows / LinuxWhat it does
Find in Current FileCmd + FCtrl + FOpens the in-editor search widget.
Replace in Current FileCmd + Option + FCtrl + HOpens find and replace fields in the active editor.
Find in Entire WorkspaceCmd + Shift + FCtrl + Shift + FSearches matching text across all files in open workspace.
Replace in Entire WorkspaceCmd + Shift + HCtrl + Shift + HGlobal find and replace across all project files.
Toggle Match CaseOption + Cmd + CAlt + CToggles case-sensitive matching in search bar.
Toggle Whole WordOption + Cmd + WAlt + WRestricts search matches to entire words.
Toggle Regular ExpressionOption + Cmd + RAlt + REnables regular expression syntax evaluation in search/replace.

Refactor & Code Formatting

Refactor / Format ActionmacOSWindows / LinuxWhat it does
Format Entire DocumentShift + Option + FShift + Alt + FFormats document according to configured formatter (Prettier, Black, Biome, rustfmt).
Format Selected CodeCmd + K, Cmd + FCtrl + K, Ctrl + FFormats only the highlighted text without touching surrounding lines.
Refactor Context MenuCtrl + Shift + RCtrl + Shift + ROpens contextual refactoring tools (extract function, extract constant, inline variable).
Organize ImportsShift + Option + OShift + Alt + OSorts import statements and removes unused dependencies.
Rename SymbolF2F2Project-wide semantic identifier rename.

Debugging & Stepping Controls

Debugging ActionmacOSWindows / LinuxWhat it does
Start / Continue DebuggingF5F5Launches debug session or resumes execution from paused breakpoint.
Start Without DebuggingCtrl + F5Ctrl + F5Executes active launch profile without halting on breakpoints.
Toggle BreakpointF9F9Sets or clears breakpoint on current line.
Step OverF10F10Executes the current statement without stepping into subroutines.
Step IntoF11F11Steps inside the function call on the active line.
Step OutShift + F11Shift + F11Executes remaining lines of current function and pauses at the caller.
Stop DebuggingShift + F5Shift + F5Terminates active debug session.
Restart DebuggingCmd + Shift + F5Ctrl + Shift + F5Restarts debugger with current launch configuration.

Git & Source Control

Git CommandmacOSWindows / LinuxWhat it does
Open Source Control PanelCtrl + Shift + GCtrl + Shift + GOpens Git source control panel to view staged and unstaged file changes.
Commit ChangesCmd + EnterCtrl + EnterCommits staged changes when focus is inside the commit message text box.
Toggle Git Diff / View ChangesCmd + K, Cmd + DCtrl + K, Ctrl + DOpens working diff view against HEAD.

Zen Mode & Focus Workspace

Focus CommandmacOSWindows / LinuxWhat it does
Toggle Zen ModeCmd + K, ZCtrl + K, ZDistraction-free full screen hiding tabs, activity bar, and sidebars.
Exit Zen ModeEsc, EscEsc, EscPress Escape twice (or repeat shortcut) to return to regular layout.
Toggle Centered Editor LayoutVia Command PaletteVia Command PaletteCenters the active editor with comfortable side margins.
Toggle Menu Bar (Win/Linux)AltAltTemporarily reveals or hides the top application menu bar on Windows/Linux.

Coming from IntelliJ IDEA or Sublime Text

If you are switching to VS Code from IntelliJ IDEA, WebStorm, PyCharm, or Sublime Text, you do not need to relearn everything from scratch: • Keymap Extensions: Search the Extensions marketplace (Cmd/Ctrl + Shift + X) for "IntelliJ IDEA Keybindings" or "Sublime Text Keymap and Settings Importer" to keep your original keystrokes. • Search Everywhere: IntelliJ uses Shift + Shift; in native VS Code, use Cmd/Ctrl + P for file search, or Cmd/Ctrl + Shift + P for all commands. • Quick Fix / Intention Actions: IntelliJ uses Alt + Enter; native VS Code uses Cmd + . (Mac) or Ctrl + . (Windows/Linux). • File Structure / Symbols: IntelliJ uses Cmd/Ctrl + F12; native VS Code uses Cmd/Ctrl + Shift + O. • Rename Symbol: Both IntelliJ and VS Code use Shift + F6 / F2.

Printable Minimal Daily Loop (Pro Workflow)

Build muscle memory around a fast, mouse-free cycle: open file, multi-cursor edit, untab, fix, rename, format, run, and commit:
Cmd/Ctrl + P          # 1. Quick open target file
Option/Alt + Click    # 2. Multi-cursor editing
Shift + Tab           # 3. Untab / unindent lines
Cmd/Ctrl + .          # 4. Quick fix / import auto-fix
F2                    # 5. Semantic rename symbol
Shift + Alt/Opt + F   # 6. Format entire document
Ctrl + F5             # 7. Run code without debugging (or F5 to debug)
Cmd/Ctrl + Enter      # 8. Commit in Git panel

Official References & Custom Keybindings File

To customize or remap shortcuts, open your User keybindings.json file: • macOS: ~/Library/Application Support/Code/User/keybindings.json • Windows: %APPDATA%\Code\User\keybindings.json • Linux: ~/.config/Code/User/keybindings.json Official Microsoft documentation: • Default Keyboard Shortcuts Reference: https://code.visualstudio.com/docs/reference/default-keybindings • Key Bindings and Customization Guide: https://code.visualstudio.com/docs/configure/keybindings

Related

Knowledge is power.