Skip to content

Latest commit

History

34 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

rano

A from-scratch rewrite of GNU nano in Rust.

What is this?

rano is a terminal text editor that aims to replicate the behavior and feel of GNU nano 8.7, built entirely in Rust. It uses crossterm for terminal I/O instead of ncurses, making it portable across platforms without C dependencies.

Features

  • Full text editing — character insertion, deletion, word/line operations, autoindent
  • Cut, copy, paste — line and region-based, with mark support
  • Search and replace — forward/backward, case-sensitive/insensitive, regex support
  • Go to line/column — jump to any position in the file
  • Undo/redo — full undo history
  • Multiple buffers — open and switch between files
  • Mouse support — click to position cursor, drag to select, scroll wheel
  • File format detection — Unix, DOS, and Mac line endings
  • Backup files — optional backup on save
  • Help viewer — built-in keybinding reference (^G)
  • RC file support — reads .nanorc configuration
  • Syntax highlighting — uses nano-compatible .nanorc syntax files (40+ languages)
  • File browser — directory navigation (behind feature flag)
  • Search/position history — persistent across sessions (behind feature flag)

Building

Requires Rust 1.70+.

cargo build --release

The binary will be at target/release/rano.

Installation

cargo build --release
sudo cp target/release/rano /usr/local/bin/

Or install directly with Cargo:

cargo install --path .

Usage

rano # Open an empty buffer
rano file.txt # Edit a file
rano -l file.txt # Show line numbers
rano -i file.txt # Enable autoindent
rano -E -T 4 file.txt # Use 4 spaces instead of tabs

Key bindings

ShortcutAction
^OSave (Write Out)
^SSave (quick)
^XExit
^WSearch
^\Search and replace
^KCut line
^UPaste
^6Set mark
^ZUndo
^YRedo
^GHelp
^_Go to line
^TSuspend

Command-line options

-l, --linenumbers Show line numbers
-m, --mouse Enable click-to-position
-c, --constantshow Always show cursor position
-i, --autoindent Auto-indent new lines
-S, --softwrap Soft-wrap long lines
-T, --tabsize <N> Set tab width (default: 8)
-E, --tabstospaces Insert spaces instead of tabs
-w, --nowrap Disable line wrapping
-x, --nohelp Hide the shortcut bar
-D, --boldtext Use bold instead of reverse video
-v, --view Read-only mode
-B, --backup Create backup files on save
-L, --nonewlines Don't add trailing newline
-I, --ignorercfiles Skip .nanorc files
-Y, --syntax <NAME> Force a syntax definition

Syntax Highlighting

rano reads nano's .nanorc syntax definition files for highlighting. It automatically searches for them in:

  • ~/.nanorc (user config with include directives)
  • /usr/share/nano/
  • /usr/local/share/nano/
  • /opt/homebrew/share/nano/ (macOS Homebrew)

If you have GNU nano installed, syntax highlighting should work out of the box. On macOS: brew install nano. On Debian/Ubuntu: apt install nano.

Supported languages include: Rust, C/C++, Python, JavaScript, Go, Java, Ruby, PHP, Shell, HTML, CSS, JSON, YAML, Markdown, SQL, and many more.

Architecture

The codebase is organized into modules that mirror nano's source files:

ModulePurpose
main.rsEntry point, CLI argument parsing (clap)
definitions.rsCore types, enums, bitflags, data structures
editor.rsCentral Editor struct, main loop, key dispatch
winio.rsTerminal I/O via crossterm, screen drawing
text.rsText editing operations, undo/redo
movement.rsCursor movement
search.rsSearch, replace, go-to-line
cut.rsCut, copy, paste
prompt.rsPrompt bar and yes/no dialogs
files.rsFile I/O, open, save, exit
global.rsKeybinding table, function table
chars.rsCharacter/string utilities, Unicode width
utils.rsPath utilities, number parsing
color.rsSyntax highlighting (feature-gated)
rcfile.rsRC file parsing
help.rsHelp viewer
history.rsSearch/position history (feature-gated)
nano.rsResize handling, word chopping, line/word/char counting
browser.rsFile browser (feature-gated)

Key design decisions

  • Vec<Line> instead of linked lists — nano uses doubly-linked lists for lines; rano uses indexed vectors for cache-friendly access and simpler code.
  • Editor struct instead of globals — all mutable state lives in a single Editor struct rather than C-style global variables.
  • crossterm instead of ncurses — no C dependencies, works on macOS/Linux.
  • bitflags for flags — type-safe flag sets instead of #define bit masks.
  • Cargo features mirror #ifdef — nano's compile-time feature flags map to Cargo features.

License

This project is a clean rewrite inspired by GNU nano. It does not contain any code from the original GNU nano project.

About

A from-scratch rewrite of GNU nano in Rust.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages