You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pass <CR> through handleInsertKeybind in insert mode.
Route normal mode <CR> through processKeystroke for keybind resolution.
Fallback to submit when normal mode <CR> has no mapping.
Document input_submit interaction and add Chinese translation.
@@ -268,11 +268,14 @@ Each keymap entry maps a key sequence to an action:
268
268
269
269
Supported built-in actions:
270
270
271
-
-`"normal"` exits insert mode and enters normal mode.
272
-
-`"insert"` enters insert mode.
273
-
-`"submit"` submits the OpenCode prompt.
271
+
| Action | Modes | Effect |
272
+
|---|---|---|
273
+
|`"submit"`| insert, normal | Submits the prompt |
274
+
|`"normal"`| insert only | Exits insert mode, enters normal mode |
275
+
|`"insert"`| normal only | Enters insert mode |
276
+
|`"<vim keys>"`| normal only | Executes the configured Vim key sequence |
274
277
275
-
Any other action string is treated as a Vim key sequence. For example, this maps `Y` to yank from the cursor to the end of the line:
278
+
For example, this maps `Y` to yank from the cursor to the end of the line:
276
279
277
280
```jsonc
278
281
"keymaps": {
@@ -282,6 +285,10 @@ Any other action string is treated as a Vim key sequence. For example, this maps
282
285
}
283
286
```
284
287
288
+
Unlike other keys, `<CR>` in normal mode defaults to `"submit"` when no mapping is configured. In insert mode, if `<CR>` is unmapped and OpenCode's `input_submit` is not `return`, it inserts a newline instead of submitting.
289
+
290
+
> **Note:** When `input_submit` is not `"return"`, make sure to also set `"input_newline": "return"` in the OpenCode `keybinds` config. Without it, `<CR>` in insert mode does nothing (neither submits nor inserts a newline).
291
+
285
292
## Keymap Syntax
286
293
287
294
Key sequences can contain printable ASCII characters, except literal spaces. Use `<Space>` for the space key.
@@ -331,7 +338,7 @@ Use `kj` or `jk` to leave insert mode:
331
338
}
332
339
```
333
340
334
-
Submit the prompt with Enter in normal mode:
341
+
Submit with `<CR>` in normal mode is the default — this keymap is optional:
0 commit comments