keybinds.mdx 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. ---
  2. title: Keybinds
  3. description: Customize your keybinds.
  4. ---
  5. OpenCode has a list of keybinds that you can customize through the OpenCode config.
  6. ```json title="opencode.json"
  7. {
  8. "$schema": "https://opencode.ai/config.json",
  9. "keybinds": {
  10. "leader": "ctrl+x",
  11. "app_exit": "ctrl+c,ctrl+d,<leader>q",
  12. "editor_open": "<leader>e",
  13. "theme_list": "<leader>t",
  14. "sidebar_toggle": "<leader>b",
  15. "scrollbar_toggle": "none",
  16. "username_toggle": "none",
  17. "status_view": "<leader>s",
  18. "tool_details": "none",
  19. "session_export": "<leader>x",
  20. "session_new": "<leader>n",
  21. "session_list": "<leader>l",
  22. "session_timeline": "<leader>g",
  23. "session_fork": "none",
  24. "session_rename": "none",
  25. "session_share": "none",
  26. "session_unshare": "none",
  27. "session_interrupt": "escape",
  28. "session_compact": "<leader>c",
  29. "session_child_cycle": "<leader>right",
  30. "session_child_cycle_reverse": "<leader>left",
  31. "session_parent": "<leader>up",
  32. "messages_page_up": "pageup",
  33. "messages_page_down": "pagedown",
  34. "messages_half_page_up": "ctrl+alt+u",
  35. "messages_half_page_down": "ctrl+alt+d",
  36. "messages_first": "ctrl+g,home",
  37. "messages_last": "ctrl+alt+g,end",
  38. "messages_next": "none",
  39. "messages_previous": "none",
  40. "messages_copy": "<leader>y",
  41. "messages_undo": "<leader>u",
  42. "messages_redo": "<leader>r",
  43. "messages_last_user": "none",
  44. "messages_toggle_conceal": "<leader>h",
  45. "model_list": "<leader>m",
  46. "model_cycle_recent": "f2",
  47. "model_cycle_recent_reverse": "shift+f2",
  48. "model_cycle_favorite": "none",
  49. "model_cycle_favorite_reverse": "none",
  50. "variant_cycle": "ctrl+t",
  51. "command_list": "ctrl+p",
  52. "agent_list": "<leader>a",
  53. "agent_cycle": "tab",
  54. "agent_cycle_reverse": "shift+tab",
  55. "input_clear": "ctrl+c",
  56. "input_paste": "ctrl+v",
  57. "input_submit": "return",
  58. "input_newline": "shift+return,ctrl+return,alt+return,ctrl+j",
  59. "input_move_left": "left,ctrl+b",
  60. "input_move_right": "right,ctrl+f",
  61. "input_move_up": "up",
  62. "input_move_down": "down",
  63. "input_select_left": "shift+left",
  64. "input_select_right": "shift+right",
  65. "input_select_up": "shift+up",
  66. "input_select_down": "shift+down",
  67. "input_line_home": "ctrl+a",
  68. "input_line_end": "ctrl+e",
  69. "input_select_line_home": "ctrl+shift+a",
  70. "input_select_line_end": "ctrl+shift+e",
  71. "input_visual_line_home": "alt+a",
  72. "input_visual_line_end": "alt+e",
  73. "input_select_visual_line_home": "alt+shift+a",
  74. "input_select_visual_line_end": "alt+shift+e",
  75. "input_buffer_home": "home",
  76. "input_buffer_end": "end",
  77. "input_select_buffer_home": "shift+home",
  78. "input_select_buffer_end": "shift+end",
  79. "input_delete_line": "ctrl+shift+d",
  80. "input_delete_to_line_end": "ctrl+k",
  81. "input_delete_to_line_start": "ctrl+u",
  82. "input_backspace": "backspace,shift+backspace",
  83. "input_delete": "ctrl+d,delete,shift+delete",
  84. "input_undo": "ctrl+-,super+z",
  85. "input_redo": "ctrl+.,super+shift+z",
  86. "input_word_forward": "alt+f,alt+right,ctrl+right",
  87. "input_word_backward": "alt+b,alt+left,ctrl+left",
  88. "input_select_word_forward": "alt+shift+f,alt+shift+right",
  89. "input_select_word_backward": "alt+shift+b,alt+shift+left",
  90. "input_delete_word_forward": "alt+d,alt+delete,ctrl+delete",
  91. "input_delete_word_backward": "ctrl+w,ctrl+backspace,alt+backspace",
  92. "history_previous": "up",
  93. "history_next": "down",
  94. "terminal_suspend": "ctrl+z",
  95. "terminal_title_toggle": "none",
  96. "tips_toggle": "<leader>h"
  97. }
  98. }
  99. ```
  100. ---
  101. ## Leader key
  102. OpenCode uses a `leader` key for most keybinds. This avoids conflicts in your terminal.
  103. By default, `ctrl+x` is the leader key and most actions require you to first press the leader key and then the shortcut. For example, to start a new session you first press `ctrl+x` and then press `n`.
  104. You don't need to use a leader key for your keybinds but we recommend doing so.
  105. ---
  106. ## Disable keybind
  107. You can disable a keybind by adding the key to your config with a value of "none".
  108. ```json title="opencode.json"
  109. {
  110. "$schema": "https://opencode.ai/config.json",
  111. "keybinds": {
  112. "session_compact": "none"
  113. }
  114. }
  115. ```
  116. ---
  117. ## Desktop prompt shortcuts
  118. The OpenCode desktop app prompt input supports common Readline/Emacs-style shortcuts for editing text. These are built-in and currently not configurable via `opencode.json`.
  119. | Shortcut | Action |
  120. | -------- | ---------------------------------------- |
  121. | `ctrl+a` | Move to start of current line |
  122. | `ctrl+e` | Move to end of current line |
  123. | `ctrl+b` | Move cursor back one character |
  124. | `ctrl+f` | Move cursor forward one character |
  125. | `alt+b` | Move cursor back one word |
  126. | `alt+f` | Move cursor forward one word |
  127. | `ctrl+d` | Delete character under cursor |
  128. | `ctrl+k` | Kill to end of line |
  129. | `ctrl+u` | Kill to start of line |
  130. | `ctrl+w` | Kill previous word |
  131. | `alt+d` | Kill next word |
  132. | `ctrl+t` | Transpose characters |
  133. | `ctrl+g` | Cancel popovers / abort running response |
  134. ---
  135. ## Shift+Enter
  136. Some terminals don't send modifier keys with Enter by default. You may need to configure your terminal to send `Shift+Enter` as an escape sequence.
  137. ### Windows Terminal
  138. Open your `settings.json` at:
  139. ```
  140. %LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json
  141. ```
  142. Add this to the root-level `actions` array:
  143. ```json
  144. "actions": [
  145. {
  146. "command": {
  147. "action": "sendInput",
  148. "input": "\u001b[13;2u"
  149. },
  150. "id": "User.sendInput.ShiftEnterCustom"
  151. }
  152. ]
  153. ```
  154. Add this to the root-level `keybindings` array:
  155. ```json
  156. "keybindings": [
  157. {
  158. "keys": "shift+enter",
  159. "id": "User.sendInput.ShiftEnterCustom"
  160. }
  161. ]
  162. ```
  163. Save the file and restart Windows Terminal or open a new tab.