# Keyboard Shortcuts

Master these keyboard shortcuts to navigate Xuanpu like a pro!

## Global Shortcuts

These shortcuts work anywhere in the application:

| Shortcut | Action | Description |
|----------|--------|-------------|
| `Cmd+K` | Command Palette | Quick access to all commands |
| `Cmd+,` | Settings | Open application settings |
| `Cmd+Q` | Quit Xuanpu | Close the application |
| `Cmd+H` | Hide Xuanpu | Minimize to dock |
| `Cmd+M` | Minimize | Minimize window |
| `Cmd+W` | Close Tab | Close current tab |
| `Cmd+Shift+W` | Close Window | Close current window |
| `Esc` | Cancel/Close | Close dialogs, panels, or cancel operations |

## Navigation

| Shortcut | Action | Description |
|----------|--------|-------------|
| `Cmd+1` through `Cmd+9` | Switch Space | Jump to space 1-9 |
| `Cmd+0` | All Spaces | Show all spaces |
| `Cmd+[` | Previous Worktree | Navigate to previous worktree |
| `Cmd+]` | Next Worktree | Navigate to next worktree |
| `Cmd+Shift+[` | Previous Project | Navigate to previous project |
| `Cmd+Shift+]` | Next Project | Navigate to next project |
| `Tab` | Next Field | Move to next input field |
| `Shift+Tab` | Previous Field | Move to previous input field |

## Project Management

| Shortcut | Action | Description |
|----------|--------|-------------|
| `Cmd+O` | Add Project | Open project picker dialog |
| `Cmd+Shift+O` | Quick Open Project | Quick project switcher |
| `Cmd+P` | Quick File Search | Search files in current worktree |
| `Cmd+Option+P` | Global File Search | Search files across all worktrees |
| `Cmd+R` | Refresh | Refresh current view |
| `Cmd+Shift+R` | Refresh All | Refresh all projects and worktrees |

## Worktree Operations

| Shortcut | Action | Description |
|----------|--------|-------------|
| `Cmd+N` | New Worktree | Create new worktree for current project |
| `Cmd+Option+N` | New Worktree with Branch | Create worktree with new branch |
| `Cmd+Option+A` | Archive Worktree | Archive current worktree |
| `Cmd+Option+Delete` | Delete Worktree | Permanently delete worktree |
| `Cmd+E` | Open in Editor | Open worktree in external editor |
| `Cmd+T` | Toggle Terminal | Show/hide terminal for worktree |
| `Cmd+Shift+T` | New Terminal | Open new terminal tab |

## Worktree Connections

| Shortcut | Action | Description |
|----------|--------|-------------|
| `Cmd+K C` | Connect Worktrees | Open connection dialog (Cmd+K then C) |
| `Cmd+Option+W` | Switch Connected | Toggle between connected worktrees |
| `Cmd+Option+C` | Quick Connect | Connect to suggested worktree |
| `Cmd+Option+D` | Diff with Connected | Compare file with connected worktree |
| `Cmd+K D` | Disconnect | Disconnect worktrees (Cmd+K then D) |
| `Cmd+K P` | Connection Panel | Toggle connection panel (Cmd+K then P) |

## AI Sessions

| Shortcut | Action | Description |
|----------|--------|-------------|
| `Cmd+Shift+A` | New AI Session | Start new AI coding session |
| `Cmd+Enter` | Send Message | Send message in AI chat |
| `Shift+Enter` | New Line | Add new line in message |
| `Cmd+Z` | Undo AI Action | Undo last AI action (OpenCode only) |
| `Cmd+Shift+Z` | Redo AI Action | Redo AI action (OpenCode only) |
| `Cmd+L` | Clear Chat | Clear AI chat history |
| `Cmd+S` | Save Session | Save current session |
| `Esc` | Cancel Operation | Stop current AI operation |

## File Operations

| Shortcut | Action | Description |
|----------|--------|-------------|
| `Cmd+S` | Save File | Save current file |
| `Cmd+Shift+S` | Save All | Save all open files |
| `Cmd+Z` | Undo | Undo last edit |
| `Cmd+Shift+Z` | Redo | Redo last edit |
| `Cmd+X` | Cut | Cut selected text |
| `Cmd+C` | Copy | Copy selected text |
| `Cmd+V` | Paste | Paste from clipboard |
| `Cmd+A` | Select All | Select all text |
| `Cmd+F` | Find | Find in current file |
| `Cmd+Shift+F` | Find in Files | Find across all files |
| `Cmd+G` | Find Next | Go to next search result |
| `Shift+Cmd+G` | Find Previous | Go to previous search result |
| `Cmd+Option+F` | Replace | Find and replace |

## Editor Shortcuts

| Shortcut | Action | Description |
|----------|--------|-------------|
| `Cmd+/` | Toggle Comment | Comment/uncomment line |
| `Cmd+Shift+/` | Block Comment | Add block comment |
| `Option+Up` | Move Line Up | Move current line up |
| `Option+Down` | Move Line Down | Move current line down |
| `Option+Shift+Up` | Copy Line Up | Duplicate line above |
| `Option+Shift+Down` | Copy Line Down | Duplicate line below |
| `Cmd+]` | Indent | Increase indentation |
| `Cmd+[` | Outdent | Decrease indentation |
| `Cmd+Shift+K` | Delete Line | Delete current line |
| `Cmd+Option+Up` | Add Cursor Above | Add cursor above |
| `Cmd+Option+Down` | Add Cursor Below | Add cursor below |
| `Cmd+D` | Select Next Match | Select next occurrence (editor only) |
| `Cmd+Shift+D` | Select All Matches | Select all occurrences |
| `F12` | Go to Definition | Jump to definition |
| `Option+F12` | Peek Definition | Preview definition inline |
| `Shift+F12` | Find References | Find all references |
| `F2` | Rename Symbol | Rename across files |

## Git Operations

| Shortcut | Action | Description |
|----------|--------|-------------|
| `Cmd+Shift+C` | Commit | Open commit dialog |
| `Cmd+Enter` | Confirm Commit | Commit with message (in dialog) |
| `Cmd+Shift+S` | Stage All | Stage all changes |
| `Cmd+Option+S` | Stage File | Stage current file |
| `Cmd+Shift+U` | Unstage All | Unstage all changes |
| `Cmd+Option+U` | Unstage File | Unstage current file |
| `Cmd+K P` | Push | Push to remote (Cmd+K then P) |
| `Cmd+K L` | Pull | Pull from remote (Cmd+K then L) |
| `Cmd+Option+D` | Discard Changes | Discard file changes |
| `Cmd+Option+H` | View History | Show git history |

## View Controls

| Shortcut | Action | Description |
|----------|--------|-------------|
| `Cmd+B` | Toggle Sidebar | Show/hide left sidebar |
| `Cmd+Shift+B` | Toggle File Tree | Show/hide file tree |
| `Cmd+J` | Toggle Panel | Show/hide bottom panel |
| `Cmd+Shift+E` | Focus Explorer | Focus file explorer |
| `Cmd+K G` | Focus Git | Focus git panel (Cmd+K then G) |
| `Cmd+Shift+X` | Focus Extensions | Focus extensions panel |
| `Cmd+\` | Split Editor | Split editor vertically |
| `Cmd+Shift+\` | Split Editor Horizontal | Split editor horizontally |
| `Cmd+Option+Left` | Focus Left Pane | Move focus left |
| `Cmd+Option+Right` | Focus Right Pane | Move focus right |

## Terminal Shortcuts

| Shortcut | Action | Description |
|----------|--------|-------------|
| `` Ctrl+` `` | Toggle Terminal | Show/hide integrated terminal |
| `Cmd+Shift+T` | New Terminal | Create new terminal instance |
| `Cmd+Shift+]` | Next Terminal | Switch to next terminal |
| `Cmd+Shift+[` | Previous Terminal | Switch to previous terminal |
| `Cmd+Shift+X` | Kill Terminal | Close current terminal |
| `Ctrl+C` | Interrupt | Send interrupt signal |
| `Ctrl+D` | Exit | Exit terminal session |
| `Ctrl+L` | Clear | Clear terminal screen |
| `Cmd+K` | Clear Buffer | Clear terminal buffer |

## Debug Shortcuts

| Shortcut | Action | Description |
|----------|--------|-------------|
| `F5` | Start/Continue | Start or continue debugging |
| `Shift+F5` | Stop | Stop debugging |
| `F9` | Toggle Breakpoint | Add/remove breakpoint |
| `F10` | Step Over | Step over line |
| `F11` | Step Into | Step into function |
| `Shift+F11` | Step Out | Step out of function |

## Window Management

| Shortcut | Action | Description |
|----------|--------|-------------|
| `Cmd+Shift+Option+N` | New Window | Open new Xuanpu window |
| `Cmd+Shift+W` | Close Window | Close current window |
| `Cmd+` ` | Cycle Windows | Cycle through Xuanpu windows |
| `Cmd+Option+M` | Minimize All | Minimize all windows |
| `F11` | Full Screen | Toggle full screen mode |

## Accessibility

| Shortcut | Action | Description |
|----------|--------|-------------|
| `Cmd++` | Zoom In | Increase font size |
| `Cmd+-` | Zoom Out | Decrease font size |
| `Cmd+0` | Reset Zoom | Reset to default size |
| `Option+Cmd+I` | Developer Tools | Open developer console |

## Custom Shortcuts

You can customize keyboard shortcuts in Settings:

1. Open Settings (`Cmd+,`)
2. Navigate to "Keyboard Shortcuts"
3. Search for the command you want to modify
4. Click on the current shortcut
5. Press your new key combination
6. Click "Save"

## Tips for Learning Shortcuts

1. **Start with essentials**: Master `Cmd+K`, `Cmd+P`, and `Cmd+N` first
2. **Print this page**: Keep it nearby while working
3. **Practice daily**: Use one new shortcut each day
4. **Customize**: Modify shortcuts to match your muscle memory
5. **Command Palette**: When you forget, use `Cmd+K` to search for commands

## Platform-Specific Notes

These shortcuts are for macOS. If Xuanpu becomes available on other platforms:

| macOS | Windows/Linux |
|-------|---------------|
| `Cmd` | `Ctrl` |
| `Option` | `Alt` |
| `Ctrl` | `Ctrl` |

---

💡 **Pro Tip**: The command palette (`Cmd+K`) shows keyboard shortcuts next to each command. Use it to discover and learn shortcuts as you work!