↑ It’s a real (tiny) editor. Go on, type something—or try Ctrl+T (5 themes), Ctrl+N, and Ctrl+K.
What Lekh does
Designed for quick config tweaks on remote servers and focused coding sessions alike—every feature earns its bytes without bloating the binary.
🧭
Zero Modes, Instant Muscle Memory
No getting trapped in command modes. Standard shortcuts (Ctrl+S save, Ctrl+Q quit, Ctrl+Z/Y undo/redo, Ctrl+C/X/V) plus full mouse click, drag selection, and scroll wheel support.
🎨
5 True-Color Themes & Bracket Glow
Press Ctrl+T to cycle Default, Dracula, Nord, OneDark, and Gruvbox in 24-bit RGB. Includes subtle current-line highlighting, glowing ()[]{} bracket pairs, and a 1-column minimap scrollbar.
🔍
Live Smart-Case Search & Replace
Press Ctrl+F to jump across matches as you type (Enter/↓ next, ↑ previous, F3 repeat) or Ctrl+R to replace all occurrences in a single undoable step.
🔢
Hybrid Relative Line Numbers
Press Ctrl+N to cycle between Absolute numbers, Vim-style Relative distance numbers (with exact line number on your cursor row), or distraction-free Off.
⏪
Group-Merged Undo & OSC 52 Copy
Consecutive typing and consecutive Backspace/Delete merge naturally into single undo steps. Copying via Ctrl+C also syncs straight to your host clipboard over SSH via OSC 52.
🛡️
Trojan-Source & Escape Armor
Hidden bidirectional Unicode overrides (CVE-2021-42574) are exposed as bold red ? markers with an immediate warning. Pasted or file control characters can never inject terminal escape sequences.
16 Languages Highlighted Out of the Box (Zero Regex Engine, Zero External Grammars)
🦀 Rust
🐍 Python
🟨 JavaScript / TypeScript
⚙️ C / C++
☕ Java / C# / Kotlin / Swift
🐹 Go
🐚 Shell / Bash / Zsh
🌐 HTML / XML (+ embedded JS & CSS)
🎨 CSS / SCSS
{} JSON
⚙️ TOML / YAML / INI
📝 Markdown
🌙 Lua
💎 Ruby
🗄️ SQL
⚡ Zig
How Lekh works under the hood
Lekh is ~4,500 lines of strictly safe Rust (#![forbid(unsafe_code)]) split into five clean, single-purpose modules—no shell-outs, no network calls, and no executed config scripts.
01 · lib.rs
0% Idle Event Loop
Sleeps in the OS kernel on event::read() using zero CPU until a key, mouse, or bracketed paste arrives—then drains queued bursts before drawing once.
02 · editor.rs
State & Coordinates
Validates cursor bounds, word jumps, smart auto-indent, 10k-char bracket matching, and multi-click selection.
03 · buffer.rs
Reversible Op Log
Stores lines as Vec<char> for O(1) column access and records algebraic inverses (Ins↔Del, Split↔Join)—never cloning full snapshots.
04 · syntax.rs
Cached Tokenizer
Single-pass scanner with multi-line state + per-line tok_cache. Editing line k only invalidates cache from line k downward.
05 · ui.rs
Single-Flush Frame
Queues only visible viewport rows into a 64 KB BufWriter and flushes once per frame—zero terminal flicker.
🔒 4-Step Crash-Proof Atomic Save (fileio.rs)
Private O_EXCL Temp File: Writes to .filename.lekh-pid-nanos.tmp with mode 0600 so planted symlinks are refused and secrets are never briefly world-readable.
Symlink & Metadata Preservation: Resolves symlinks so saving updates the real target without breaking your symlink, copying original permissions and preserving BOM + LF/CRLF line endings.
Hardware fsync(): Calls sync_all() on both the temp file and parent directory so bytes hit physical storage.
Atomic POSIX rename(): Swaps the directory entry in one atomic kernel operation—power loss can never leave a truncated 0-byte file.
🛡️ Hostile-Input & Modification Guards
Refuses Traps: Blocks directories, FIFOs, and device nodes (running lk /dev/zero exits cleanly instead of hanging or eating RAM).
Binary & Size Protection: Refuses non-UTF-8 or NUL-byte binaries so executables are never silently mangled, with a configurable 64 MB cap (LEKH_MAX_MB).
Disk-Change Detection: Checks file mtime before saving—if another process modified the file after you opened it, Lekh asks before overwriting.
Panic-Safe Terminal Restore: A RAII TermGuard + custom panic hook guarantees raw mode and alternate screen are always cleaned up.
Download & install
The fastest way to get started is downloading a precompiled release binary directly from GitHub Releases—or building with Cargo in one command.
📦 Official Prebuilt Binaries on GitHub Releases
Every tagged release includes ready-to-run binaries (both lk and lekh) so you can download, extract, and run immediately without installing Rust.
Run on Windows (PowerShell, Windows Terminal & cmd.exe)
Option 1 — One-Line PowerShell Setup (Recommended, no SmartScreen popup): Installs bothlk and lekh onto your Windows User PATH automatically without needing Rust or Cargo:
irm https://github.com/khajumsanjog/Lekh/releases/latest/download/install.ps1 | iex
# Now run from ANY folder in PowerShell or cmd.exe:
lk index.html
lekh index.html
Option 2 — Graphical Setup Installer: Download and run lekh-windows-x86_64-setup.exe on GitHub Releases to install both lk.exe and lekh.exe into %LOCALAPPDATA%\Programs\Lekh and register them on your PATH.
Compile & Install from GitHub Source (Rust 1.74+)
Installing from source compiles an LTO-optimized, stripped binary and places bothlekh and the short alias lk onto your ~/.cargo/bin PATH:
Cut whole line, Duplicate line, Indent / Dedent single line or multi-line selection
Find & Replace
Ctrl+F · F3 / Shift+F3 · Ctrl+R
Live incremental smart-case search, next/previous match, Replace All
Navigation
Ctrl+L · Ctrl+←/→ · Home / End
Go to line[:col], jump by word (Option+←/→ on Mac), smart Home toggle
Selection & Mouse
Shift+Move · Ctrl+A · Mouse
Click to place cursor, drag to select, double-click word, triple-click line, wheel scroll
Themes & View
Ctrl+T · Ctrl+N · Ctrl+P · Ctrl+G
Cycle 5 themes, cycle Absolute/Relative/Off line numbers, toggle auto-indent, Help
How Lekh Compares
Capability
GNU Nano
Vim / Neovim
Lekh (lk)
Learning curve
Zero (on-screen hints)
Steep modal grammar
Zero (familiar Ctrl shortcuts)
Memory safety
C (manual memory)
C / Lua
100% Safe Rust (forbid(unsafe))
Syntax highlighting
Regex files required
Built-in / Tree-sitter
16 languages compiled into binary
True-Color themes & bracket glow
Limited
Via config
5 built-in themes on Ctrl+T
Trojan-Source Unicode defense
No
Plugin needed
Built-in red ? badge + warning
How do I paste text from my browser or another app into Lekh?
Use your terminal’s standard system paste shortcut (Cmd+V on macOS, Ctrl+Shift+V on Linux/Windows Terminal). Lekh supports bracketed paste—meaning pasted code won’t trigger runaway auto-indentation, and dangerous control bytes are stripped automatically.
Why are there two commands: lekh and lk?
Both binaries are built from the exact same codebase: lekh is the expressive full name, and lk saves keystrokes when you’re opening dozens of files a day in the terminal.