diff --git a/CHANGELOG.md b/CHANGELOG.md index bed1dd5..cee1a82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Version ## [Unreleased] +### Added + +- `:w` and `:write` now send the prompt instead of autocompleting to `:wq` and quitting OpenCode. Sessions auto-persist, so the natural mapping for vim users' reflexive "save" is to submit the current prompt. `:wq` still quits. + ## [0.15.3] — 2026-07-01 ### Fixed diff --git a/README.md b/README.md index 99c76b7..104c6af 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,7 @@ All normal-mode motions work for extending the selection: `h` `j` `k` `l` `w` `b | `Ctrl+r` | Redo | | `p` | Paste from yank register | | `:` | Command palette | +| `:w` `:write` | Send prompt (via command palette) | | `:q` `:quit` `:wq` | Quit OpenCode (via command palette) | | `:vim` | Toggle vim mode on/off (persisted across restarts) | | `/` | Jump to message (session timeline) | diff --git a/src/index.ts b/src/index.ts index 7fe99d4..f5f6433 100644 --- a/src/index.ts +++ b/src/index.ts @@ -263,9 +263,22 @@ const plugin: TuiPluginModule = { slashName: cmd, run: exitRun, })); + const submitRun = async () => { + setTimeout(() => api.keymap.dispatchCommand("input.submit"), 0); + }; + const submitCommands = ["w", "write"].map((cmd) => ({ + name: `vimcode.${cmd}`, + title: `:${cmd}`, + category: "Vim", + namespace: "palette", + desc: "Send prompt", + slashName: cmd, + run: submitRun, + })); api.keymap.registerLayer?.({ commands: [ ...exitCommands, + ...submitCommands, { name: "vimcode.vim", title: ":vim",