Visual Studio Code keyboard shortcuts for editing and navigation
Open the VS Code Command Palette with Ctrl+Shift+P on Windows or Linux and ⌘+Shift+P on macOS. Use the Keyboard Shortcuts editor to look up or change a binding. The tables cover common defaults for editing, folding, and navigation.
Find commands, files, and lines
These are defaults for a standard US layout. On macOS, ⌘ is Command and Control is a different key.
| Task | Windows | Linux | macOS |
|---|---|---|---|
| Open Command Palette | Ctrl+Shift+P | Ctrl+Shift+P | ⌘+Shift+P |
| Open file by name | Ctrl+P | Ctrl+P | ⌘+P |
| Go to line in current file | Ctrl+G | Ctrl+G | Control+G |
| Open Keyboard Shortcuts | Ctrl+K, Ctrl+S | Ctrl+K, Ctrl+S | ⌘+K, ⌘+S |
Comma-separated combinations are entered in sequence. For Ctrl+K, Ctrl+S, press and release the first combination, then press the second. Use Quick Open to search for a file and the Command Palette to search for an action.
Comment, edit, and fold code
| Task | Windows | Linux | macOS |
|---|---|---|---|
| Toggle line comment | Ctrl+/ | Ctrl+/ | ⌘+/ |
| Toggle block comment | Shift+Alt+A | Ctrl+Shift+A | Shift+Option+A |
| Duplicate line downward | Shift+Alt+Down | Ctrl+Shift+Alt+Down | Shift+Option+Down |
| Format document | Shift+Alt+F | Ctrl+Shift+I | Shift+Option+F |
| Fold current region | Ctrl+Shift+[ | Ctrl+Shift+[ | ⌘+Option+[ |
| Unfold current region | Ctrl+Shift+] | Ctrl+Shift+] | ⌘+Option+] |
| Fold all regions | Ctrl+K, Ctrl+0 | Ctrl+K, Ctrl+0 | ⌘+K, ⌘+0 |
| Unfold all regions | Ctrl+K, Ctrl+J | Ctrl+K, Ctrl+J | ⌘+K, ⌘+J |
Focus the editor before using these. Comments follow the current language mode. Folding needs a foldable region, and Format Document needs an available formatter.
Microsoft’s default keyboard shortcuts reference
Change the case of selected text
- Select
draft_namein the editor and open the Command Palette. - Search for
transformand choose Transform to Uppercase. The selection becomesDRAFT_NAME. Select the result and run Transform to Lowercase to reverse it.
Change a shortcut and restore its default
- Open Keyboard Shortcuts, search for the command, and choose the pencil beside it.
- Press the desired keys and save with Enter. Test the binding with focus in the intended editor or view.
- To restore the default, right-click the changed entry and choose Reset Keybinding.
Diagnose a shortcut that does not work
If the keys run a different command, right-click the entry and use Show Same Keybindings. Check whether a custom binding, keymap extension, or focus condition changes which entry applies.
Run Developer: Toggle Keyboard Shortcuts Troubleshooting from the Command Palette and try the keys. The Output panel shows what VS Code received and the command it chose. If no event appears, check system shortcuts, the layout, and the input method. Toggle logging off when finished.




