opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat(tui): add vi basic mode extension for prompt and editor

Open ryanwyler opened this issue 1 week ago • 4 comments

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_basic KV setting to enable/disable
  • vi_basic_clip_x KV setting for clipboard behavior
  • Toggle via command menu

Architecture

  • PromptExtension interface for modular prompt extensions
  • lineNumbers option for gutter redraw (opentui workaround)
  • Two modes: full (for standalone editors) and prompt (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

ryanwyler avatar Jan 06 '26 02:01 ryanwyler