vimltui
A self-contained, embeddable Vim editor for Ratatui TUI applications.
Drop a fully functional Vim editor into any Ratatui app. Each VimEditor instance owns its own text buffer, cursor, mode, undo/redo history, search, and registers — zero shared state with your application.
Features
| Category | Commands |
|---|---|
| Modes | Normal, Insert, Visual (Char / Line / Block) |
| Motions | h j k l w b e W B E 0 ^ $ gg G f F t T |
| Operators | d c y > < gu gU (composable: dw ci" y$ >j ...) |
| Text Objects | iw i" i' i( i{ |
| Editing | x s r ~ o O p P u Ctrl+R . |
| Search | / ? n N with match highlighting |
| Command | :w :q :q! :wq :x :123 |
| Visual Ops | d y > < on selection |
| Count Prefix | 3j 2dw 5x |
| Clipboard | System clipboard via wl-copy / xclip / xsel |
| Rendering | Relative line numbers, search highlights, visual selection, cursor |
Installation
Add to your Cargo.toml:
[]
= "0.1"
Quick Start
use ;
// Full editor
let mut editor = new;
// Read-only viewer (no insert mode)
let mut viewer = new;
Handling Input
use EditorAction;
// In your event loop, pass key events to the editor:
let action = editor.handle_key;
match action
Rendering
Use the built-in renderer with a VimTheme and a SyntaxHighlighter:
use ;
use Color;
let theme = VimTheme ;
// In your render function:
render;
Custom Syntax Highlighting
Implement the SyntaxHighlighter trait:
use SyntaxHighlighter;
use Span;
use ;
;
Architecture
VimEditor (self-contained)
├── lines: Vec<String> — owned text buffer
├── cursor_row / cursor_col — cursor position
├── mode: VimMode — Normal / Insert / Visual
├── undo_stack / redo_stack — snapshot-based undo
├── search: SearchState — /pattern with highlights
├── unnamed_register: Register — yank/delete clipboard
├── pending_operator / count — operator + motion state machine
└── config: VimModeConfig — restrict available modes
Key events flow through handle_key() → internal state machine → EditorAction returned to your app. The editor never reaches into your application state.
Used By
License
MIT - see LICENSE