[PR #12679] feat(tui): vim motions in prompt input #14322

Open
opened 2026-02-16 18:19:07 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12679

State: open
Merged: No


What does this PR do?

Closes #1764
Closes #11111

Adds optional Vim motions to the prompt input. Enable with tui.vim: true or toggle from the menu. Disabled by default.

Screenshot 2026-02-10 at 9 12 32 PM

Supported:

  • Mode switching: i I a A o O S, cc, cw, Esc
  • Motions: h j k l, w b e, W B E, 0 ^ $
  • Deletes: x, dd, dw
  • Session navigation: gg/G
  • Scrolling: Ctrl+e/y/d/u/f/b
  • Enter in normal mode submits

Motivation: I use OpenCode daily and the external editor round-trip for small edits was slow. I originally built this for personal use and then cleaned it up for upstream.

Implementation: Vim state isolated in /vim module. Handler owns mode + pending operator state. Mode resets to insert after submit. No visual mode, intentionally excluded to avoid conflicts with the clipboard system.

I saw thdxr's concern in #1764 about partial Vim feeling incomplete. This PR covers only the core motions needed for prompt editing and is intentionally kept small to make review manageable. I have a fuller implementation locally (yank/put, word/line selections like daw/diw, yaw/yiw, history cycling with j/k, and menu navigation) that I can split into follow-up PRs if this direction looks good.

How did you verify your code works?

Used the fuller implementation locally for over a week of daily use. Reimplemented the core subset for this PR and verified manually (editing, scrolling, session switching, edge cases with pending operators, empty buffers, multiline). Added targeted tests for mode transitions, motions, deletes, pending state, and submit reset. All passing.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12679 **State:** open **Merged:** No --- ### What does this PR do? Closes #1764 Closes #11111 Adds optional Vim motions to the prompt input. Enable with tui.vim: true or toggle from the menu. Disabled by default. <img width="1091" height="120" alt="Screenshot 2026-02-10 at 9 12 32 PM" src="https://github.com/user-attachments/assets/03fced47-b704-473b-be77-23928ba87980" /> Supported: - Mode switching: `i I a A o O S`, `cc`, `cw`, `Esc` - Motions: `h j k l`, `w b e`, `W B E`, `0 ^ $` - Deletes: `x`, `dd`, `dw` - Session navigation: `gg/G` - Scrolling: `Ctrl+e/y/d/u/f/b` - `Enter` in normal mode submits Motivation: I use OpenCode daily and the external editor round-trip for small edits was slow. I originally built this for personal use and then cleaned it up for upstream. Implementation: Vim state isolated in `/vim` module. Handler owns mode + pending operator state. Mode resets to insert after submit. No visual mode, intentionally excluded to avoid conflicts with the clipboard system. I saw thdxr's concern in #1764 about partial Vim feeling incomplete. This PR covers only the core motions needed for prompt editing and is intentionally kept small to make review manageable. I have a fuller implementation locally (yank/put, word/line selections like daw/diw, yaw/yiw, history cycling with j/k, and menu navigation) that I can split into follow-up PRs if this direction looks good. ### How did you verify your code works? Used the fuller implementation locally for over a week of daily use. Reimplemented the core subset for this PR and verified manually (editing, scrolling, session switching, edge cases with pending operators, empty buffers, multiline). Added targeted tests for mode transitions, motions, deletes, pending state, and submit reset. All passing.
yindo added the pull-request label 2026-02-16 18:19:07 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14322