Keybindings

Visual Studio Code offers a powerful and flexible way to customize your keybindings to match your workflow. You can rebind any command to your preferred key combination.

Default Keybindings

VS Code comes with a comprehensive set of default keybindings for various operating systems. These are designed to be ergonomic and efficient.

Common Keybindings (Windows/Linux)

Command Default Shortcut
Show All Commands Ctrl+Shift+P
Open Settings Ctrl+,
Toggle Terminal Ctrl+`
Save File Ctrl+S
Save All Ctrl+K S
Copy Line Up Alt+Up Arrow
Copy Line Down Alt+Down Arrow
Delete Line Shift+Delete
Find Ctrl+F
Replace Ctrl+H
Go to Definition F12
Peek Definition Alt+F12
Toggle Sidebar Ctrl+B
Close Editor Ctrl+W

Common Keybindings (macOS)

Command Default Shortcut
Show All Commands Cmd+Shift+P
Open Settings Cmd+,
Toggle Terminal Ctrl+`
Save File Cmd+S
Save All Cmd+K S
Copy Line Up Option+Up Arrow
Copy Line Down Option+Down Arrow
Delete Line Cmd+Delete
Find Cmd+F
Replace Cmd+Option+F
Go to Definition F12
Peek Definition Option+F12
Toggle Sidebar Cmd+B
Close Editor Cmd+W

Customizing Keybindings

You can easily customize keybindings through the Keyboard Shortcuts editor. To open it:

  1. Press Ctrl+K Ctrl+S (or Cmd+K Cmd+S on macOS).
  2. Alternatively, go to File > Preferences > Keyboard Shortcuts (or Code > Preferences > Keyboard Shortcuts on macOS).

The editor displays all available commands and their assigned keybindings. You can:

The keybindings.json File

For more direct control and to manage complex configurations, VS Code uses a keybindings.json file. You can access this file by clicking the `{}` icon in the top right corner of the Keyboard Shortcuts editor.

Here's an example of how to add a custom keybinding:

{
    "key": "ctrl+alt+c",
    "command": "workbench.action.showCommands",
    "when": "editorTextFocus"
}

This example assigns the "Show All Commands" action to Ctrl+Alt+C, but only when the editor has focus.

Keybinding Conflicts

If multiple keybindings are assigned to the same command, or if a keybinding is assigned to multiple commands, VS Code will highlight these conflicts in the Keyboard Shortcuts editor. You can resolve conflicts by removing or changing one of the conflicting keybindings.

Tip: You can import keymaps from other popular editors like Sublime Text, Atom, and Emacs via the Extensions Marketplace. Search for "keymap" to find them.

Common Keybinding Concepts

Mastering VS Code's keybindings can significantly boost your productivity. Experiment with customizations to find what works best for you!