> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/opencode-ai/opencode/llms.txt
> Use this file to discover all available pages before exploring further.

# Keyboard shortcuts

> Complete reference of keyboard shortcuts for OpenCode's terminal interface

OpenCode provides vim-style keyboard shortcuts and intuitive key bindings for efficient navigation and control.

## Global shortcuts

These shortcuts work throughout the application:

| Shortcut | Action                                             |
| -------- | -------------------------------------------------- |
| `Ctrl+C` | Quit application (shows confirmation dialog)       |
| `Ctrl+?` | Toggle help dialog showing all available shortcuts |
| `?`      | Toggle help dialog (when not in editing mode)      |
| `Ctrl+L` | View application logs                              |
| `Ctrl+S` | Switch to a different session                      |
| `Ctrl+K` | Open command palette                               |
| `Ctrl+O` | Open model selection dialog                        |
| `Ctrl+T` | Open theme switcher                                |
| `Ctrl+F` | Open file picker to select files for upload        |
| `Esc`    | Close current dialog or overlay                    |

<Tip>
  Press `Ctrl+?` at any time to see context-sensitive shortcuts based on your current location in the application.
</Tip>

## Chat page shortcuts

When in the main chat interface:

| Shortcut | Action                                          |
| -------- | ----------------------------------------------- |
| `Ctrl+N` | Create a new session (clears current chat)      |
| `Ctrl+X` | Cancel current AI operation or generation       |
| `i`      | Focus editor (when not already in writing mode) |
| `Esc`    | Exit writing mode and focus messages            |

<Note>
  The `i` key only focuses the editor when you're not already typing. This mimics vim's insert mode behavior.
</Note>

## Editor shortcuts

When the message editor is focused:

| Shortcut         | Action                                                        |
| ---------------- | ------------------------------------------------------------- |
| `Enter`          | Send message (when editor is not focused)                     |
| `Ctrl+S`         | Send message (when editor is focused)                         |
| `\` + `Enter`    | Add a newline without sending the message                     |
| `Ctrl+E`         | Open external editor (set via `$EDITOR` environment variable) |
| `Esc`            | Blur editor and focus messages                                |
| `Ctrl+R` + `0-9` | Delete attachment at the specified index                      |
| `Ctrl+R` + `R`   | Delete all attachments                                        |
| `Esc`            | Cancel attachment delete mode                                 |

<Tip>
  Use `Ctrl+E` to compose longer messages in your preferred editor like vim or nano. OpenCode creates a temporary markdown file for editing.
</Tip>

## Message navigation

Navigate through the conversation history:

| Shortcut      | Action                  |
| ------------- | ----------------------- |
| `PgUp` or `b` | Scroll up one page      |
| `PgDn` or `f` | Scroll down one page    |
| `Ctrl+U`      | Scroll up half a page   |
| `Ctrl+D`      | Scroll down half a page |

<Note>
  These vim-style navigation keys (`b`, `f`, `Ctrl+U`, `Ctrl+D`) work throughout the message area for efficient scrolling.
</Note>

## Session dialog shortcuts

When the session switcher is open (`Ctrl+S`):

| Shortcut   | Action                         |
| ---------- | ------------------------------ |
| `↑` or `k` | Move to previous session       |
| `↓` or `j` | Move to next session           |
| `Enter`    | Select the highlighted session |
| `Esc`      | Close dialog without switching |

## Model dialog shortcuts

When the model selection dialog is open (`Ctrl+O`):

| Shortcut   | Action                              |
| ---------- | ----------------------------------- |
| `↑` or `k` | Move up in model list               |
| `↓` or `j` | Move down in model list             |
| `←` or `h` | Switch to previous provider         |
| `→` or `l` | Switch to next provider             |
| `Enter`    | Select the highlighted model        |
| `Esc`      | Close dialog without changing model |

<Tip>
  Use the horizontal navigation (`h`/`l` or arrow keys) to quickly browse models from different providers like OpenAI, Anthropic, and Google.
</Tip>

## Permission dialog shortcuts

When the AI requests permission to perform an action:

| Shortcut           | Action                              |
| ------------------ | ----------------------------------- |
| `←` or `Left`      | Switch to previous option           |
| `→` or `Right`     | Switch to next option               |
| `Tab`              | Switch to next option               |
| `Enter` or `Space` | Confirm the selected option         |
| `a`                | Allow permission (one time)         |
| `s`                | Allow permission for entire session |
| `d`                | Deny permission                     |

<Note>
  The permission dialog displays diffs, commands, or URLs for you to review before approving. Use the viewport navigation shortcuts to scroll through large previews.
</Note>

## Command dialog shortcuts

When the command palette is open (`Ctrl+K`):

| Shortcut   | Action                          |
| ---------- | ------------------------------- |
| `↑` or `k` | Move to previous command        |
| `↓` or `j` | Move to next command            |
| `Enter`    | Execute the highlighted command |
| `Esc`      | Close dialog without executing  |

## Theme dialog shortcuts

When the theme switcher is open (`Ctrl+T`):

| Shortcut   | Action                              |
| ---------- | ----------------------------------- |
| `↑` or `k` | Move to previous theme              |
| `↓` or `j` | Move to next theme                  |
| `Enter`    | Apply the highlighted theme         |
| `Esc`      | Close dialog without changing theme |

## File picker shortcuts

When the file picker is open (`Ctrl+F`):

| Shortcut   | Action                              |
| ---------- | ----------------------------------- |
| `↑` or `k` | Move to previous file/directory     |
| `↓` or `j` | Move to next file/directory         |
| `Enter`    | Select file or enter directory      |
| `Esc`      | Close file picker without selecting |
| Arrow keys | Navigate file tree                  |

## Logs page shortcuts

When viewing logs (`Ctrl+L`):

| Shortcut            | Action              |
| ------------------- | ------------------- |
| `Esc`               | Return to chat page |
| `Backspace`         | Return to chat page |
| `q`                 | Return to chat page |
| `PgUp` / `PgDn`     | Scroll through logs |
| `Ctrl+U` / `Ctrl+D` | Half-page scroll    |

## Completion dialog shortcuts

When using the `@` completion feature:

| Shortcut   | Action                         |
| ---------- | ------------------------------ |
| `@`        | Trigger file/folder completion |
| `↑` or `k` | Previous completion option     |
| `↓` or `j` | Next completion option         |
| `Enter`    | Select highlighted completion  |
| `Esc`      | Close completion dialog        |

<Tip>
  Type `@` in the editor to autocomplete file and folder names, making it easy to reference specific files in your messages.
</Tip>

## Vim-style navigation summary

OpenCode embraces vim keybindings for familiarity:

<CardGroup cols={2}>
  <Card title="Movement" icon="arrows-up-down">
    * `j` / `k` for up/down
    * `h` / `l` for left/right
    * `Ctrl+U` / `Ctrl+D` for half-page scrolls
  </Card>

  <Card title="Modes" icon="keyboard">
    * `i` to enter insert mode (focus editor)
    * `Esc` to exit insert mode
    * `?` for help (similar to vim's `:help`)
  </Card>
</CardGroup>

## Quick reference table

Print this table for quick reference:

<AccordionGroup>
  <Accordion title="Core actions">
    | Action           | Shortcut            |
    | ---------------- | ------------------- |
    | Send message     | `Enter` or `Ctrl+S` |
    | New session      | `Ctrl+N`            |
    | Switch session   | `Ctrl+S`            |
    | Cancel operation | `Ctrl+X`            |
    | Open commands    | `Ctrl+K`            |
    | Change model     | `Ctrl+O`            |
    | View help        | `Ctrl+?` or `?`     |
  </Accordion>

  <Accordion title="Navigation">
    | Action         | Shortcut      |
    | -------------- | ------------- |
    | Page up        | `PgUp` or `b` |
    | Page down      | `PgDn` or `f` |
    | Half page up   | `Ctrl+U`      |
    | Half page down | `Ctrl+D`      |
    | Move up        | `↑` or `k`    |
    | Move down      | `↓` or `j`    |
  </Accordion>

  <Accordion title="Dialogs">
    | Action            | Shortcut           |
    | ----------------- | ------------------ |
    | Close dialog      | `Esc`              |
    | Confirm selection | `Enter`            |
    | Switch options    | `←` / `→` or `Tab` |
    | Files             | `Ctrl+F`           |
    | Themes            | `Ctrl+T`           |
    | Logs              | `Ctrl+L`           |
  </Accordion>

  <Accordion title="Permissions">
    | Action            | Shortcut           |
    | ----------------- | ------------------ |
    | Allow once        | `a`                |
    | Allow for session | `s`                |
    | Deny              | `d`                |
    | Navigate options  | `←` / `→` / `Tab`  |
    | Confirm           | `Enter` or `Space` |
  </Accordion>
</AccordionGroup>

<Note>
  Custom keybindings are not currently supported, but shortcuts follow common terminal application conventions and vim patterns for familiarity.
</Note>
