Home

Awesome

edtui

EdTUI

Overview

EdTUI is a text editor widget for the Ratatui ecosystem. It is designed to provide a light-weight user experience inspired by Vim.

use edtui::{EditorState, EditorTheme, EditorView};
use ratatui::widgets::Widget;

let mut state = EditorState::default();
EditorView::new(&mut state)
        .theme(EditorTheme::default())
        .render(area, buf)

Features

Keybindings

EdTUI offers a set of keybindings similar to Vim. Here are some of the most common keybindings:

Normal/Visual Mode:
KeybindingDescription
iEnter Insert mode
vEnter Visual mode
h, j, k, lNavigate left, down, up, and right
w, bMove forward or backward by word
xDelete the character under the cursor
DelDelete the character left of the cursor
u, <ctrl>+rUndo/Redo last action
EscEscape Insert mode or Visual mode
0Move cursor to start of line
^Move cursor to first non-blank character
$Move cursor to end of line
aAppend after the cursor
AAppend at the end of the line
oAdd a new line below and enter Insert mode
OAdd a new line above and enter Insert mode
BackspaceDelete the previous character
dDelete the selection
ddDelete the current line
ciwSelect between delimiters. Supported: ["]
uUndo the last change
rRedo the last undone action
yCopy the selected text
pPaste the copied text
Insert Mode:
KeybindingDescription
EscReturn to Normal mode

For more keybindings and customization options, refer to the code.

Demo

Experimental Mouse Support

Edtui now includes experimental mouse support. To enable it activate the feature

[dependencies.edtui]
version = "0.7"
features = ["mouse-support"]

and use the mouse event handler

let event_handler = EditorEvent::default();
event_handler.on_mouse_event(mouse_event, &mut state);

Note: This feature is experimental, so expect potential bugs and breaking changes.

Roadmap

License: MIT