Skip to content

kagesyntax/OxideEdit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Notepad

A Vim-inspired modal text editor built with Rust and ratatui, providing a lightweight, terminal-based editing experience with familiar Vim keybindings.

Features

Modal Editing

  • 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

Vim-Compatible Keybindings

Motions

  • h/j/k/l - Left/Down/Up/Right navigation
  • w/W - Jump forward to word start
  • b/B - Jump backward to word start
  • e/E - Jump forward to word end
  • 0 - Jump to line start
  • $ - Jump to line end
  • ^ - Jump to first non-whitespace character
  • gg - Jump to file start
  • G - Jump to file end or specific line
  • % - Jump to matching bracket
  • f/F/t/T - Find characters forward/backward

Operators

  • d - Delete (with motions: dw, dd, d$, etc.)
  • c - Change (delete and enter insert mode)
  • y - Yank/copy to register
  • > - Indent
  • < - Outdent

Text Objects

  • iw/aw - Inner/around word
  • i"/a", i'/a' - Inner/around quotes
  • ib/ab, iB/aB - Inner/around parentheses/braces
  • i[/a[ - Inner/around brackets
  • i</a< - Inner/around angle brackets

Editing

  • i/I/a/A/o/O - Enter insert mode at various positions
  • x/X - Delete character under/before cursor
  • r - Replace single character
  • ~ - Toggle case
  • s/S - Substitute character/line
  • J - Join lines
  • u - Undo
  • Ctrl+r - Redo
  • . - Repeat last change (dot-repeat)

Visual Mode

  • v - Enter character-wise visual mode
  • V - Enter line-wise visual mode
  • Motion keys to extend selection
  • Operators (d, y, c) on selected text

Search & Replace

  • /pattern - Search forward with regex
  • ?pattern - Search backward with regex
  • n/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

Marks

  • m{a-z} - Set mark
  • '{a-z} - Jump to mark (line-wise)
  • `{a-z}` - Jump to mark (precise position)

Scrolling

  • Ctrl+d/Ctrl+u - Half-page down/up
  • Ctrl+f/Ctrl+b - Full page down/up
  • zz/zt/zb - Center/top/bottom current line

Command Mode

  • :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

Additional Features

  • 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 regex crate
  • 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

Installation

Prerequisites

  • Rust 1.75+ (Edition 2024)
  • A terminal emulator with UTF-8 support

Build from Source

# 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]

Install via Cargo

cargo install --path .

Usage

# Open a file
notepad myfile.txt

# Start with empty buffer
notepad

Key Commands Quick Reference

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

Architecture

The editor is organized into the following modules:

  • buffer - Text buffer management (load, save, insert, delete)
  • editor - Core editor state and high-level operations
  • mode - Editing mode enumeration and display
  • motion - Cursor movement commands (h, j, k, l, w, b, e, etc.)
  • operator - Text operators (delete, change, yank, indent) and text objects
  • keymap - Key event handling and mode-specific input processing
  • command - Ex-style command execution and search/replace
  • render - Terminal UI rendering with ratatui

Dependencies

  • 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

Configuration

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)

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgments

  • Inspired by Vim modal editing philosophy
  • Built with ratatui terminal UI framework
  • Uses crossterm for terminal manipulation

About

A Vim-inspired modal terminal text editor built with Rust and Ratatui, featuring undo/redo, regex search, and text objects.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages