How to Add Keyboard Shortcuts in VS Code

Learn to create, customize, and share keyboard shortcuts in Visual Studio Code with practical steps, examples, and best practices for Windows, macOS, and Linux.

Shortcuts Lib
Shortcuts Lib Team
·5 min read
VS Code Shortcuts - Shortcuts Lib
Photo by RaniRamlivia Pixabay
Quick AnswerSteps

You're about to learn how to add keyboard shortcuts in VS Code, including using the Keyboard Shortcuts UI, editing keybindings.json, and syncing across machines. This guide covers Windows, macOS, and Linux, with OS-specific examples and safety tips. According to Shortcuts Lib, customizing shortcuts can dramatically speed up coding, reduce repetitive tasks, and help you stay consistent across projects.

What you’ll achieve with keyboard shortcuts in VS Code

Mastering keyboard shortcuts in Visual Studio Code unlocks a faster, more focused coding flow. With the right bindings, you can navigate files, edit text, manage terminals, run commands, and switch themes without leaving the keyboard. This is not about memorizing every binding; it's about creating a small, deliberate set that aligns with your daily tasks. According to Shortcuts Lib, personalized shortcuts are the fastest path to fluency with any development tool, because they reduce context switching and cognitive load. In this guide, you’ll learn how to identify essential commands, add them to VS Code's keybinding system, and keep those bindings portable across projects and machines. You’ll see OS-specific examples for Windows, macOS, and Linux, along with best practices to avoid conflicts. The goal is not to overwhelm you with dozens of bindings, but to give you a practical starter kit you can grow over time. As you implement bindings, you’ll notice smoother navigation through the Command Palette, faster text editing, and quicker access to integrated features like the Terminal, Debug Console, and Extensions. The payoff is measurable in your daily workflow: less mouse reliance, fewer keystrokes, and more mental bandwidth for solving real problems.

Understanding VS Code keybinding anatomy

Keybindings in VS Code are composed of a command, a key sequence, and an optional condition (the when clause). Default bindings come from the editor itself, but you can override or suppress them with user or workspace bindings. User keybindings apply to your account across machines, while workspace bindings apply only to the current project folder. The When context allows you to restrict shortcuts to certain editors, languages, or states (e.g., when a terminal is focused). This architecture means you can build a personalized, portable shortcut map that works consistently across your projects, without trampling the defaults used by teammates.

Getting to the Keyboard Shortcuts editor

There are two primary ways to reach the keyboard bindings editor in VS Code. The UI approach is fast: open the Command Palette (Ctrl+P or Ctrl+Shift+P on Windows/Linux; Cmd+P or Cmd+Shift+P on macOS), and type Open Keyboard Shortcuts, then select the item. The second path is to navigate through the menu: File > Preferences > Keyboard Shortcuts (Code > Preferences on macOS). The Keyboard Shortcuts editor shows a searchable list of commands with their current bindings and an option to rebind. You can click the pencil icon to edit or double-click any item to pick a new shortcut. If you prefer, you can also open keybindings.json directly to enter bindings in JSON syntax for advanced scenarios.

Creating and editing keybindings: JSON vs UI

VS Code offers both a UI-based editor and direct JSON editing for keybindings. The UI is ideal for beginners: search for a command, click to bind, and VS Code updates keybindings.json automatically. For power users, editing keybindings.json gives precise control, supports complex sequences, and allows bulk changes via a single file. When editing JSON, each binding is an object with fields like key, command, when, and args. You can bind multiple commands to a single key sequence or create layered bindings that depend on the editor state. Keep a backup of your keybindings.json in case you need to revert, and use consistent naming conventions to stay organized.

Practical examples: common tasks and ready-to-use shortcuts

Here are practical examples you can copy into your keybindings.json or apply via the UI. The first example uses a global binding to open the Command Palette: { "key": "ctrl+k ctrl+s", "command": "workbench.action.openGlobalKeybindings" }. On macOS, use the equivalent Cmd keys: { "key": "cmd+k cmd+s", "command": "workbench.action.openGlobalKeybindings" }. Other useful bindings: - Focus Terminal: { "key": "ctrl+`", "command": "workbench.action.terminal.focus" } - Save File: { "key": "ctrl+s", "command": "workbench.action.files.save" } - Quick Open: { "key": "ctrl+p", "command": "workbench.action.quickOpen" }. Remember to check for conflicts and adjust with the When clause to avoid clobbering OS shortcuts or extension bindings.

Sharing, syncing, and exporting your keybindings

To keep bindings consistent across devices, enable Settings Sync in VS Code (on the Command Palette: Preferences: Turn on Settings Sync). This feature syncs keybindings.json, settings, extensions, and UI state across your machines. You can also manually export or copy your keybindings.json file to a USB drive or a cloud folder. If you rely on a team, consider exporting common keybindings to a shared repository or a dotfiles manager so everyone can adopt a standardized workflow without manual reconfiguration.

Troubleshooting and best practices

If a shortcut stops working, check for conflicts with other shortcuts, language-specific bindings, or OS-level bindings. Use the Keyboard Shortcuts editor’s built-in search to identify where a binding is defined, and review the When clause to ensure the command isn’t gated by an unexpected condition. Extensions may override or steal bindings, so disable problematic extensions temporarily to diagnose. Best practices include starting with a small, high-impact set of shortcuts, documenting them for teammates, and keeping your keybindings.json under version control if you’re working on multiple machines or with a team.

Tools & Materials

  • Visual Studio Code installed (latest stable release)(Ensure cross-platform consistency by testing on Windows, macOS, and Linux)
  • Keyboard and OS-specific knowledge of modifier keys(Know the differences: Ctrl/Cmd, Alt/Option, Shift)
  • Access to keybindings.json (optional for advanced editing)(Back up before editing; consider version control)
  • Access to official docs (keyboard shortcuts and command references)(Useful for validating bindings and exploring context keys)

Steps

Estimated time: 20-40 minutes

  1. 1

    Open Keyboard Shortcuts editor

    Open VS Code and access the Keyboard Shortcuts editor via the Command Palette (Ctrl+K, Ctrl+S on Windows/Linux; Cmd+K, Cmd+S on macOS). The UI lists commands with their current bindings, and you can search to find the ones you use most. This step sets the foundation for customizing shortcuts without editing files directly.

    Tip: Use the search bar to quickly locate a command; you can filter by language or scope to see relevant bindings.
  2. 2

    Identify high-impact commands to bind

    Browse the list and identify commands you perform frequently but run via the mouse. Common candidates include opening the Command Palette, showing integrated terminal, formatting code, and navigating between files. Prioritize those that reduce repetitive actions and improve your flow.

    Tip: Aim for 3–6 core bindings at first; add more as you become comfortable with the new shortcuts.
  3. 3

    Bind a command in the UI

    Click the pencil icon next to a command in the UI to bind a new shortcut. Press the key combination you want to assign, and VS Code will show conflicts if the key is already used. Save the binding to update keybindings.json automatically.

    Tip: If you see a conflict, choose a different combination or assign the conflict to a more specific context using the When clause.
  4. 4

    Edit keybindings.json directly

    Open keybindings.json to create or adjust bindings with JSON syntax. Each binding is a JSON object containing key, command, and optionally when and args fields. This method is best for advanced users who want bulk edits or precise context rules.

    Tip: Keep a consistent structure and comment your changes; although JSON doesn’t support comments in VS Code, you can maintain a separate changelog.
  5. 5

    Add OS-specific and workflow-specific bindings

    Include OS-specific key sequences to avoid cross-platform confusion. Use the When clause to limit bindings to certain editors or states, ensuring that bindings don’t override essential OS shortcuts or extensions.

    Tip: Test bindings in both Windows and macOS spaces if you work cross-platform.
  6. 6

    Test and iterate your starter kit

    Run through typical tasks with the new shortcuts, adjusting any bindings that feel awkward or conflict with your extensions. Document the changes and keep a running list of bindings you use most often.

    Tip: Consider keeping a quick-reference cheatsheet near your workspace for the first few days.
  7. 7

    Enable Settings Sync to propagate across devices

    Turn on Settings Sync to keep keybindings.json and your VS Code settings consistent across machines. This ensures your preferred shortcuts travel with you, preserving your workflow wherever you code.

    Tip: Review synced settings on new devices to confirm bindings apply correctly in your environment.
  8. 8

    Share and standardize with teammates

    Publish a shared keybinding profile or part of your keybindings.json to a team repository so teammates can adopt a common workflow. This reduces onboarding time and friction when switching between machines or projects.

    Tip: Version-control your binding changes to track evolution and rationale.
  9. 9

    Backup and maintain bindings

    Keep regular backups of keybindings.json and periodically prune bindings that are no longer helpful. As your workflow evolves, refresh your bindings to reflect new tools and extensions.

    Tip: Store backups in a trusted cloud folder or version-controlled dotfiles repo.
Pro Tip: Start with a small, useful set of shortcuts to build muscle memory without overload.
Warning: Avoid overwriting OS-level shortcuts that you rely on (e.g., Cmd+C on macOS).
Note: Use the UI first to discover commands; switch to JSON only for advanced scenarios.
Warning: Back up keybindings.json before making large changes to avoid accidental loss.

Questions & Answers

How do I reset keybindings to default in VS Code?

Open Keyboard Shortcuts (Ctrl+K Ctrl+S) and click the { } icon at the top-right to edit keybindings.json. Remove your custom bindings or delete the file to revert to defaults. You can rebind as needed afterward.

Open the shortcuts editor, clear your custom bindings, and VS Code will revert to defaults.

Can I share my keybindings with teammates?

Yes. Use Settings Sync to propagate bindings across devices, or export keybindings.json and commit it to a shared repository. Document any project-specific bindings for teammates.

You can sync across devices or share your keybindings file with your team.

What if a binding conflicts with an OS shortcut?

Check the When clause and either choose an alternative binding or scope it to a particular editor or state. Avoid reusing OS-level shortcuts unless you’re certain they won’t cause issues.

Resolve OS conflicts by reassigning or scoping the binding with a When clause.

Where are my keybindings stored?

User keybindings are stored in your keybindings.json file. Workspace bindings live alongside your project in the .vscode folder. You can edit these directly or through the Keyboard Shortcuts UI.

Keybindings live in keybindings.json; workspaces have their own bindings too.

How do I bind a command not listed in the UI?

Use keybindings.json to bind to any command by name, including internal commands or commands added by extensions. If you don’t see a command, verify the exact command ID in the command palette or extension docs.

If a command isn’t visible, check its exact ID in the palette or docs and bind that ID in JSON.

What about macOS vs Windows shortcuts?

Many bindings differ by OS due to modifier keys. Use OS-specific bindings and test on both platforms if you work across machines. Consistency is improved by using When contexts to avoid cross-platform conflicts.

Account for platform differences and test on each OS you use.

Watch Video

Main Points

  • Start with essential bindings to build muscle memory
  • Use the UI for discovery; JSON for control
  • Keep bindings OS-aware and conflict-free
  • Sync and share to maintain consistency across devices
Process diagram showing opening Keyboard Shortcuts, binding a command, and saving
How to add keyboard shortcuts in VS Code: a process

Related Articles