pi-vim
Quick reference
Section titled “Quick reference”- Use it for: Edit the main prompt modally and provide optional modal text fields in suite dialogs.
- Enable: Select
packages/pi-vim/src/index.tswithpi config. - Controls: Vim modes/motions; Ctrl+X Ctrl+E for external editor (main Insert/idle Normal); Ctrl+X Ctrl+F for files (main Insert). No slash command/global shortcut.
- Settings: Pi’s
piVimsettings; clipboard mirror all by default. Settings load at session start; shellmodeChangeis global-only. - Requirements, cost & privacy: TUI;
fdfor recursive file search, one-level fallback without it. No inference calls. Clipboard mirroring exports register text; external editor/hooks run locally. - Integrations & limits: Optional embedded consumers, stash, navigation and footer. Explicit Downloads browsing is newest-modified-first; project/home ranking is unchanged. Only one Vim editor.
pi-vim replaces Pi’s prompt editor with a Vim-style modal editor: Insert, Normal, Visual and Visual-line modes, motions, operators with counts, text objects, undo/redo, . repeat, and an EX line. It also answers a suite event-bus request for an embedded editor, so text fields in other suite dialogs can be modal too. The editing engine is pi-vim 0.14.2 (MIT, lajarre); the suite adds the embedded-editor provider, the integration protocol and transcript scrolling.
Enable and requirements
Section titled “Enable and requirements”Entry: packages/pi-vim/src/index.ts. Follow Install & select, or merge this object into your packages array:
{ "packages": [ { "source": "git:github.com/justmytwospence/pi-plugins", "extensions": ["packages/pi-vim/src/index.ts"], "skills": [], "prompts": [], "themes": [] } ]}Remove npm:pi-vim first. Two vim editors fight over the prompt; when the standalone package’s editor or its mode events are detected, the suite copy warns once that only one copy should be enabled.
Requirements and costs: Pi’s interactive TUI. There are no external services or model requests. The OS clipboard mirror uses Pi’s clipboard support. An optional modeChange hook runs a shell command you configure (below). The suite manifest lists pi-vim first, so it is installed before pi-status-footer wraps the editor’s borders and before pi-stash wraps the editor factory.
Modes and the prompt
Section titled “Modes and the prompt”Escape (or Ctrl+[) leaves Insert for Normal. In idle Normal mode (no count, operator, pending motion or EX line), Escape reaches Pi, which by default means app.interrupt; Visual mode and pending commands handle Escape locally. The footer shows the current mode, and the cursor shape follows it on terminals that support it.
The EX line on the main prompt is a bridge to Pi, not Vim’s ex language. :name args runs the Pi slash command of that name, :!cmd runs cmd through Pi’s shell (:!!cmd keeps it out of context), and the draft is snapshotted before dispatch and restored after. :q quits Pi only when the prompt is empty; :q! forces it. Names Vim reserves for its own ex commands, such as :s, :g and :w, are never dispatched, and anything unknown produces a warning instead of reaching the model.
Ctrl+U and Ctrl+D jump to the previous/next transcript checkpoint in Insert and idle Normal mode on the fullscreen main prompt; there is no need to press Escape first. The draft and mode are preserved, and Ctrl+D never exits main Pi. Stops include your prompts and feedback, concluding assistant responses, and explicitly declared plan/report/shell deliveries. Routine tools, progress and thinking-only output are skipped; this does not interpret prose. Navigation does not wrap or resume following new output; use the transcript end action for that. Groups are one visible stop, and historical plugin records without checkpoint metadata are skipped. See transcript checkpoints for the extension hooks. Visual, EX and pending states keep their local behavior. In regular, non-fullscreen mode there is no transcript viewport, so in Insert and idle Normal these keys are consumed without scrolling or editing.
Motion cheatsheet
Section titled “Motion cheatsheet”These are draft motions, not transcript navigation. Escape (or Ctrl+[) enters Normal; i resumes Insert. The supported-motion reference at the imported upstream revision covers the full engine and its Vim differences.
| Task | Keys / examples |
|---|---|
| Move by character, line or word | h j k l, w b e; 3w moves three words. |
| Move within the draft | 0 line start, ^ first nonblank, $ line end, gg / G draft start/end; gj / gk move by wrapped screen row. |
| Insert or open a line | i a I A, o O. |
| Operate on a motion / line | dw, cw, yw; dd, cc, yy; counts such as 2dd. |
| Select / paste | v character Visual, V line Visual; p / P. A terminal paste or a file dragged in while in Normal or Visual inserts its text after the cursor, like p, and stays in Normal. |
| Undo / redo / repeat | u, Ctrl+R, .. |
| Sentences, lines and columns | ( ) sentences, + - next/previous line, | column, g_ last nonblank, ge / gE back to a word end. |
| Case, shift and numbers | ~, g~ / gu / gU / g? with a motion (gUiw, guu), >> / << / >ip, Ctrl+A / Ctrl+X on a number. |
| Text objects | Words, ip / ap, is / as, it / at, il / al, brackets and quotes (outside one, the next one on the line). |
| Word search | * / # (and g* / g#) jump to the word under the cursor, n / N repeat. |
| Replace and reselect | R Replace mode (Backspace restores), gv last selection, gi Insert where you left it. |
| Visual | p / P replace the selection and keep the register; ~ u U case, > < shift, J / gJ join, r replace, text objects (vi(, vip). |
Operators, counts and text objects are supported. Every register name is the unnamed register except "_, the black hole. Macros, marks, block Visual, / search and general Vim EX semantics are not: an unsupported command that takes a key (qa, @a, ma, 'a, zz, ]x) drops that key rather than running it as a command.
Plugin behavior
Section titled “Plugin behavior”pi-vim reproduces three popular Vim plugins; each has a setting to turn it off.
- surround.vim:
ys{motion}{char}(ysiw),ysiw(with inner spaces,ysiwtthen a tag ending in>or Enter,ysiwfthen a function name),yssfor the line,ySSon its own lines;ds{char};cs{old}{new}(cs"',cs)],cst<p>); VisualS{char}..repeats them and the unnamed register is left alone. - targets.vim: pair, quote, separator (
, . ; : + - = ~ _ * # / | \ & $), argument (a) and tag text objects that seek the next or previous one on the line, withI/A(inside without blanks, around with one side’s blank),nfor the next object (cin(),bfor any bracket andqfor any quote. The targets.viml(last) modifier is not available:il/alare Neovim’s line objects. - vim-wordmotion: lowercase
w,b,e,ge,iwandawstop insideCamelCase,ACRONYMWords,snake_caseandkebab-case;W,B,EandiWstill use whole WORDs.
Neovim (with these plugins loaded for their cases) is the reference: the package’s parity tests run every case in both editors. On the main prompt, Ctrl+U/D navigate checkpoints in Insert and idle Normal; in embedded editors, idle Normal pages the offered host viewport. With pi-copy loaded / and ? open its copy mode over the whole transcript. Keymap & focus compares main and embedded behavior.
Finding files
Section titled “Finding files”In Insert mode on the main prompt, Ctrl+X Ctrl+F (Vim’s file-name completion) opens a fuzzy file finder and inserts the chosen path as an @ mention, the way Pi’s @ autocomplete does. A plain query searches the project with fd, respecting .gitignore, and, once you type something, your home directory too (four levels deep, skipping hidden entries), so download finds ~/Downloads from any project; matches from both are ranked together, project first on ties. Start the query with ~/, /, ./ or ../ to search only below that directory (four levels deep; hidden entries are skipped for ~/ and / themselves), for example ~/Downloads/inv. Directory segments match fuzzily too: an exact name wins, then the shortest name starting with the segment, then the best fuzzy match, so ~/dl/inv searches ~/Downloads and ~/pr/pi-pl/READ finds ~/Projects/pi-plugins/README.md. Hidden directories match only when the segment starts with .. Up/Down (or Ctrl+P/N, Ctrl+K/J) move, Tab descends into a directory, Enter inserts and Escape cancels. Project paths are inserted relative to the project, others with ~/ or as absolute paths. Without fd, only one directory level is listed.
When explicitly browsing ~/Downloads/ or a descendant, entries are sorted by newest modification time first; fuzzy filtering keeps that order rather than ranking by match score. The rule applies after fuzzy directory resolution, so ~/dl/ gets the same order. Ordinary project/home searches keep their existing fuzzy ranking. The picker reads timestamps asynchronously, at most 16 at a time, and caches the listing and recency for its lifetime. Unreadable/missing times sort last, with alphabetical ties. A newest modified first hint identifies this mode; close and reopen to refresh cached timestamps.
On the main prompt, Ctrl+X Ctrl+E opens Pi’s external editor in Insert or idle Normal mode, matching the shell convention. It invokes app.editor.external even if that action’s direct keybinding is disabled. Embedded dialogs, pending Vim commands, and EX input keep their own keys.
Ctrl+X waits one second for the second key. Any other key, or the timeout, passes Ctrl+X on. In Normal mode it then decrements the number at or after the cursor, like Vim; on a line without a number, and in Insert mode, it reaches Pi’s default binding (app.message.copy), after the delay.
Embedded editors in suite dialogs
Section titled “Embedded editors in suite dialogs”pi-vim answers the pi-plugins.editor-factory.v1 request on Pi’s event bus while a session is active. A dialog that asks gets a multi-line modal editor; a dialog that gets no answer uses Pi’s native editor. Current consumers include pi-ask-user-question’s free-text answer, pi-diff-review’s comment editor and the pi-subagents session view’s editor.
An embedded editor never reaches Pi’s agent, command registry, shell or process:
- Escape is local first (Insert to Normal, Visual to Normal, drop pending keys, close the EX line). Only Escape in idle Normal mode cancels the dialog.
:w,:wqand:xsubmit. The:qfamily cancels, refusing with a warning while the editor has text unless you add!. Other EX commands,/commandsand!shelllines are not dispatched.- Ctrl+U and Ctrl+D in idle Normal mode scroll the dialog’s own viewport when it provides one; otherwise they are consumed.
Editors are disposed when their dialog closes and at session shutdown. The editor also exposes the suite’s input-context, mode and draft-snapshot protocol, which pi-select-nav, pi-next-prompt and pi-stash use to leave its keys alone or restore its cursor and mode. See keyboard & focus.
Settings
Section titled “Settings”Settings live under a piVim key in Pi’s own settings files, ~/.pi/agent/settings.json and a trusted project’s .pi/settings.json. They are read at session start, and invalid values produce a warning. For example:
{ "piVim": { "clipboardMirror": "yank", "exCommand": { "piDispatch": true, "copyInputToClipboard": false } }}clipboardMirror:all(default),yankornever; which register writes are mirrored to the OS clipboard.displayLineMotion:truemakes Normal and Visual mode treat each wrapped screen row as its own line:j/k,0/^/$,gg/G,dd/yy/cc/S/D/C/Y,dj/yk,V,o/Oand linewisepall work on rows. Yanked rows keep no soft-wrap breaks; opening or pasting a line between two rows splits the underlying line there. Insert mode is unaffected. Defaultfalse.wordMotion,targetsandsurround:falseturns off the vim-wordmotion, targets.vim or surround.vim behavior described above. Defaulttrueeach.exCommand.piDispatchturns the EX bridge to Pi commands off whenfalse;copyInputToClipboardcopies the prompt before each dispatch.modeColors,borderSyncandlabelSyncchoose per-mode colors for the input border and the footer label.modeChangeruns a shell command when the main or embedded editor changes mode. Because it executes commands, it is read only from the global settings file; a project file cannot set it.
See the local motion cheatsheet and full key reference at the imported upstream revision for Vim differences and limits; block Visual mode, macros, marks, / search and Vim ex semantics are out of scope.
GitHub source, including the entry point and the integration contract.