
# Keyboard shortcuts

`Mod` is `Cmd` on macOS and `Ctrl` everywhere else — every table below uses it that way. A
shortcut fires wherever the workbench has focus; where a table says "editor" or "explorer", the
caret or the row focus has to be inside that pane first.

## General and palette

| Shortcut                 | Action                                          |
| ------------------------ | ----------------------------------------------- |
| `Mod-P`                  | Open the palette on files                       |
| `Mod-K` or `Mod-Shift-P` | Open the palette on commands                    |
| `Mod-Shift-O`            | Open the palette on symbols in the file showing |
| `Mod-S`                  | Save the file showing                           |
| `` Mod-` ``              | Toggle the panel                                |
| `Escape`                 | Close the palette, a quick pick, or a menu      |

Toggle Sidebar and Toggle Secondary Side Bar have no shortcut — run them from the command
palette. On a narrow screen there's no room in the activity bar for anything else, so it carries
a Commands button that opens the palette directly instead.

:read-more{to="/guide/navigation"}

## File explorer

Arrow keys move the focused row; typing a character opens the filter field with that character
already in it, the way VS Code's type-to-filter does.

| Shortcut              | Action                                                               |
| --------------------- | -------------------------------------------------------------------- |
| `ArrowUp`/`ArrowDown` | Move the focused row                                                 |
| `ArrowRight`          | Open a file, expand a folder, or step into an open one's first child |
| `ArrowLeft`           | Collapse an open folder, or step out to its parent                   |
| `Home`/`End`          | Jump to the first or last visible row                                |
| `Enter`               | Rename the focused row                                               |
| `Mod-X`               | Cut the focused row                                                  |
| `Mod-C`               | Copy the focused row                                                 |
| `Mod-V`               | Paste into the focused row's directory                               |
| `Escape`              | Clear the filter, or cancel a rename                                 |

:read-more{to="/guide/files"}

## Tabs and editors

| Shortcut | Action                        |
| -------- | ----------------------------- |
| `Mod-S`  | Save the active editor's file |

## Editing

CodeMirror's own keymap covers the rest of text editing — arrow keys, `Backspace`/`Delete`,
`Mod-A` select all, word and line navigation and so on. These are the ones worth knowing beyond
that:

| Shortcut                                    | Action                                                                    |
| ------------------------------------------- | ------------------------------------------------------------------------- |
| `Mod-Z`                                     | Undo                                                                      |
| `Mod-Y` (`Mod-Shift-Z` on Mac)              | Redo                                                                      |
| `Tab` / `Shift-Tab`                         | Indent / outdent                                                          |
| `Mod-]` / `Mod-[`                           | Indent / outdent                                                          |
| `Mod-/`                                     | Toggle line comment                                                       |
| `Alt-ArrowUp` / `Alt-ArrowDown`             | Move the line up / down                                                   |
| `Shift-Alt-ArrowUp` / `Shift-Alt-ArrowDown` | Copy the line up / down                                                   |
| `Mod-Alt-ArrowUp` / `Mod-Alt-ArrowDown`     | Add a cursor above / below                                                |
| `Mod-D`                                     | Select the word, then each next occurrence of it                          |
| `Shift-Mod-K`                               | Delete the line                                                           |
| `Backspace`                                 | Deletes a bracket pair together when the caret sits between one it closed |

A language provider — a language server, for instance — adds these on top, where one is
registered for the file:

| Shortcut                                       | Action                                  |
| ---------------------------------------------- | --------------------------------------- |
| `F12` or `Mod`-click                           | Go to definition                        |
| `F2`                                           | Rename symbol                           |
| `Shift-Alt-F`                                  | Format document                         |
| `Mod-.`                                        | Quick fix                               |
| `Shift-Alt-ArrowRight` / `Shift-Alt-ArrowLeft` | Expand / shrink the selection by syntax |

:read-more{to="/guide/navigation"}

## Find

| Shortcut                     | Action                                     |
| ---------------------------- | ------------------------------------------ |
| `Mod-F`                      | Open find (seeded with the selection)      |
| `Mod-H` (`Mod-Alt-F` on Mac) | Open find and replace                      |
| `Enter` / `Shift-Enter`      | Next / previous match, from the find field |
| `Mod-Alt-Enter`              | Replace all, from the find field           |
| `Escape`                     | Close find                                 |

## Panel and side bars

| Shortcut    | Action           |
| ----------- | ---------------- |
| `` Mod-` `` | Toggle the panel |

The sidebar, the secondary side bar and the theme picker have no bound key — reach them from
their activity bar icons or the command palette.
