Crate vim_line

Crate vim_line 

Source
Expand description

vim-line: A line-oriented vim motions library for TUI applications

This crate provides a trait-based interface for line editing with vim-style keybindings. It’s designed for “one-shot” editing scenarios like REPLs, chat inputs, and command lines - not full buffer/file editing.

§Design Philosophy

  • Host-agnostic: The library doesn’t know about terminals or rendering
  • Command-based: Returns mutations for the host to apply
  • Caller owns text: The library never stores your text buffer
  • Multi-line aware: Supports inputs with newlines that grow/shrink

§Example

use vim_line::{LineEditor, VimLineEditor, Key, KeyCode};

let mut editor = VimLineEditor::new();
let mut text = String::from("hello world");

// Process 'dw' to delete word
let _ = editor.handle_key(Key::char('d'), &text);
let result = editor.handle_key(Key::char('w'), &text);

// Apply edits
for edit in result.edits.into_iter().rev() {
    edit.apply(&mut text);
}
// text is now "world"

Structs§

EditResult
Result of processing a key event.
Key
A key event.
VimLineEditor
A vim-style line editor.

Enums§

Action
Actions the editor can request from the host.
KeyCode
Key codes for non-character keys.
TextEdit
A single text mutation.

Traits§

LineEditor
The contract between a line editor and its host application.