A Vim-inspired modal text editor built with Rust and ratatui, providing a lightweight, terminal-based editing experience with familiar Vim keybindings.
- Normal Mode - Navigate and manipulate text with powerful Vim motions
- Insert Mode - Type and edit text naturally
- Visual Mode - Select text character-by-character for operations
- Visual Line Mode - Select entire lines for batch operations
- Command Mode - Execute Ex-style commands (
:w,:q,:wq, etc.) - Search Mode - Search forward (
/) or backward (?) with regex patterns - Replace Mode - Overwrite existing text character by character
h/j/k/l- Left/Down/Up/Right navigationw/W- Jump forward to word startb/B- Jump backward to word starte/E- Jump forward to word end0- Jump to line start$- Jump to line end^- Jump to first non-whitespace charactergg- Jump to file startG- Jump to file end or specific line%- Jump to matching bracketf/F/t/T- Find characters forward/backward
d- Delete (with motions:dw,dd,d$, etc.)c- Change (delete and enter insert mode)y- Yank/copy to register>- Indent<- Outdent
iw/aw- Inner/around wordi"/a",i'/a'- Inner/around quotesib/ab,iB/aB- Inner/around parentheses/bracesi[/a[- Inner/around bracketsi</a<- Inner/around angle brackets
i/I/a/A/o/O- Enter insert mode at various positionsx/X- Delete character under/before cursorr- Replace single character~- Toggle cases/S- Substitute character/lineJ- Join linesu- UndoCtrl+r- Redo.- Repeat last change (dot-repeat)
v- Enter character-wise visual modeV- Enter line-wise visual mode- Motion keys to extend selection
- Operators (
d,y,c) on selected text
/pattern- Search forward with regex?pattern- Search backward with regexn/N- Repeat search forward/backward*- Search for word under cursor:s/old/new/- Substitute on current line:%s/old/new/g- Global substitute:noh- Clear search highlighting
m{a-z}- Set mark'{a-z}- Jump to mark (line-wise)`{a-z}`- Jump to mark (precise position)
Ctrl+d/Ctrl+u- Half-page down/upCtrl+f/Ctrl+b- Full page down/upzz/zt/zb- Center/top/bottom current line
:w- Save file:q- Quit (fails if unsaved):q!- Quit without saving:wq/:x- Save and quit:w {filename}- Save as:e {filename}- Edit file:{line}- Jump to line number:noh- Clear search highlights
- Count prefixes - Use numbers before commands (e.g.,
3w,5dd) - Undo/Redo stack - Up to 1000 undo levels
- Registers - Single register for yank/delete/paste operations
- Regex search - Full regex support via the
regexcrate - Auto-indentation - Preserves indentation on new lines
- Status bar - Shows mode, filename, modification status, and cursor position
- Line numbers - Relative line number display in the gutter
- Search highlighting - Visual highlighting of search matches
- Rust 1.75+ (Edition 2024)
- A terminal emulator with UTF-8 support
# Clone the repository
git clone https://github.com/yourusername/notepad.git
cd notepad
# Build in release mode
cargo build --release
# Run
./target/release/notepad [filename]cargo install --path .# Open a file
notepad myfile.txt
# Start with empty buffer
notepad| Action | Command |
|---|---|
| Enter insert mode | i (at cursor), a (after), I (line start), A (line end) |
| Save file | :w |
| Quit | :q or :q! (discard changes) |
| Save and quit | :wq or :x |
| Undo | u |
| Redo | Ctrl+r |
| Delete word | dw |
| Delete line | dd |
| Copy line | yy |
| Paste | p (after), P (before) |
| Search forward | /pattern |
| Search backward | ?pattern |
| Repeat search | n / N |
The editor is organized into the following modules:
buffer- Text buffer management (load, save, insert, delete)editor- Core editor state and high-level operationsmode- Editing mode enumeration and displaymotion- Cursor movement commands (h, j, k, l, w, b, e, etc.)operator- Text operators (delete, change, yank, indent) and text objectskeymap- Key event handling and mode-specific input processingcommand- Ex-style command execution and search/replacerender- Terminal UI rendering with ratatui
- ratatui (0.28) - Terminal UI framework
- crossterm (0.28) - Terminal manipulation (input, screen control)
- regex (1.x) - Regular expression search
- unicode-width (0.1) - Unicode character width calculation
The editor uses optimized release settings for minimal binary size and maximum performance:
[profile.release]
opt-level = "z" # Optimize for size
lto = true # Link-time optimization
codegen-units = 1 # Single codegen unit for better optimization
strip = true # Strip symbols
panic = "abort" # Abort on panic (smaller binary)MIT License
Contributions are welcome! Please feel free to submit a Pull Request.