# Keyboard

Source: https://athas.dev/docs/keyboard

Customize shortcuts, learn the common defaults, and edit with Vim mode.

Athas shortcuts are configurable. `Cmd/Ctrl` in these docs means Command on macOS and Control
on Windows and Linux. A selected preset, a custom binding or the focused pane can change an
action's keys.

## Customize shortcuts

Open Settings (`Cmd+,` on macOS, `Ctrl+,` elsewhere) and go to **Keyboard**. Search for a command,
inspect its binding and edit it with the shortcut recorder. Choose a keybinding preset if you want
a familiar starting point, and use import and export to move custom keybindings between machines.

## Common default shortcuts

| Action             | Shortcut           |
| ------------------ | ------------------ |
| Open folder        | `Cmd/Ctrl+O`       |
| Quick Open         | `Cmd/Ctrl+P`       |
| Command palette    | `Cmd/Ctrl+Shift+P` |
| Save               | `Cmd/Ctrl+S`       |
| Save as            | `Cmd/Ctrl+Shift+S` |
| Save all           | `Cmd/Ctrl+Alt+S`   |
| Close tab          | `Cmd/Ctrl+W`       |
| Reopen tab         | `Cmd/Ctrl+Shift+T` |
| Find in editor     | `Cmd/Ctrl+F`       |
| Global search      | `Cmd/Ctrl+Shift+F` |
| Show/hide terminal | `Cmd/Ctrl+J`       |
| Show/hide sidebar  | `Cmd/Ctrl+B`       |

The command palette shows each action with its current shortcut, so it is the easiest way to
discover commands and the keys bound to them.

## Focus and conflicts

A binding may apply only while the editor or terminal has focus. For example, `Cmd/Ctrl+D`
selects the next occurrence in the editor but splits a focused terminal to the right. Check the
current focus and keymap when a shortcut invokes the wrong action.

Source Control has no shortcut in the Athas preset: `Cmd/Ctrl+Shift+G` is Find Previous there, as
it is in the VS Code preset. The VS Code preset binds Source Control to `Ctrl+Shift+G`
specifically, on every platform.

[Diagnostics](https://athas.dev/docs/diagnostics) uses `Cmd/Ctrl+Shift+J` in the Athas preset and
`Cmd/Ctrl+Shift+M` in the VS Code preset.

## Vim mode

Vim mode adds modal editing to the Athas editor. It does not load your Neovim configuration or
provide a Neovim plugin runtime.

Turn on **Vim Mode** in Settings, and enable relative line numbers if you prefer them for
movement. Use `i` to enter Insert mode and `Esc` to return to Normal mode. The command palette
also includes **Vim: Enter … Mode** actions.

| Command              | Action                                           |
| -------------------- | ------------------------------------------------ |
| `:w`                 | Save current file                                |
| `:wq` or `:x`        | Save and close current file                      |
| `:q`                 | Close current file through the normal close flow |
| `:q!`                | Force close current file without saving          |
| `:command` or `:cmd` | Open the command palette                         |
| `:explore` or `:Ex`  | Open file navigation                             |
| `:preview`           | Toggle Markdown preview for a Markdown buffer    |

Vim handles keys inside the editor, while Athas shortcuts control workspaces and other panes, so
bindings can depend on Normal or Insert mode and on which pane has focus. Start with a disposable
file when learning commands that delete text or close unsaved buffers.

For a full external terminal editor, choose Neovim, Helix, Vim or a custom command in the editor
settings. That workflow uses your external executable and configuration.
