feat(tui): add vi basic mode extension for prompt and editor
Summary
A modular vi mode implementation for the OpenCode TUI prompt with support for standalone editors.
Provides the vi extension for prompt but also for the Project Files Viewer and Editor https://github.com/anomalyco/opencode/pull/7017
Core Features
- Normal/insert modes with standard vi keybindings
- Movement:
h/j/k/l,w/b/e,0/$,G,{/},%,g{n}g,ctrl+f/b - Delete:
x,{n}x,dd,d{n}d,dw,d{n}w,D,d$,dG,d{n}G - Change:
cc,c{n}c,cw,c{n}w,C,s - Yank:
yy,y{n}y,y$,yG,y%,y{,y} - Paste:
p/P(line-wise or character-wise) - Multiline:
o,O,J - Other:
r,~,.,u,ctrl+r - Search:
/,?,n,N(with regex support) - Search operators:
d/,d?,c/,c?,y/,y?
Configuration
-
prompt_vi_basicKV setting to enable/disable -
vi_basic_clip_xKV setting for clipboard behavior - Toggle via command menu
Architecture
-
PromptExtensioninterface for modular prompt extensions -
lineNumbersoption for gutter redraw (opentui workaround) - Two modes:
full(for standalone editors) andprompt(for prompt input)
Files Changed
| File | Changes |
|---|---|
lib/vi-basic-core.ts |
Core vi mode logic |
lib/vi-basic-extension.tsx |
Prompt extension wrapper |
lib/prompt-extension.ts |
Extension interface |
component/prompt/index.tsx |
Integration |
The following comment was made by an LLM, it may be inaccurate:
Duplicate PR Check Results for PR #7016
✅ No duplicate PRs found.
While the search found several related PRs focused on TUI keybindings and navigation, none are duplicates of PR #7016:
Related (but distinct) PRs:
- #6448 - feat(tui): [EXPERIMENTAL] Vim-style window system with extensible plugin views - This is a broader vim-style window system, not the specific vi mode keybinding implementation in this PR
- #5255 - feat(tui): add ctrl+arrow word navigation in prompt - Word navigation enhancement, different scope
- #3888 - feat: add keybindings reference dialog to TUI - Keybindings documentation, not vi mode implementation
- #6753 - feat(keybinds): support physical keycode-based keybindings for non-English layouts - General keybinding infrastructure, not vi mode specific
PR #7016 is unique as it implements a modular vi basic mode extension with specific vi keybindings (h/j/k/l, yank, delete, change, search operators, etc.) for the prompt component. This hasn't been addressed in any other open PR.
Enable VI prompt in Command Menu
Thanks for your contribution!
This PR doesn't have a linked issue. All PRs must reference an existing issue.
Please:
- Open an issue describing the bug/feature (if one doesn't exist)
- Add
Fixes #<number>orCloses #<number>to this PR description
See CONTRIBUTING.md for details.
Closing PR, will use for personal use. Branch available on my fork if you want it.