A modal TUI text editor for prose and screenplay writing, built with Go and Bubble Tea.
Performance: Optimized for large documents with lazy word wrapping (handles 10,000+ line files smoothly)
- β Modal interface (Read Mode / Edit Mode)
- β File loading and creation
- β Manual save (Ctrl+S)
- β Auto-save every 30 minutes
- β Full text editing (insert, delete, backspace, enter)
- β Line navigation with arrow keys and vim keys (hjkl)
- β Page navigation (PgUp/PgDn)
- β Document start/end navigation (Ctrl+Home/End, g/G)
- β Status bar with mode indicator, filename, and position
- β Modified indicator [+]
- β Colored status messages
- β Lazy word wrapping (3,192x faster for large files!)
- β Visible cursor in both Read and Edit modes (different styles)
- β
Command mode (
:in Read Mode) - β On-demand spell-checking with dictionary downloads
- β File tree sidebar (F1) with directory navigation
- β Smart cache invalidation for optimal performance
- Toggle sidebar: Press F1 to show/hide the file tree
- Navigate: Arrow keys (ββ) or vim keys (j/k)
- Expand/collapse folders: Press Enter on directories
- Select files: Press Enter on files (opens in editor - coming soon)
- Auto-scroll: Viewport automatically scrolls to keep selection visible
- Smart filtering: Hides hidden files, node_modules, vendor directories
- Visual indicators: π/π for folders, π for files
- Lazy wrapping: Only processes visible lines (not entire document)
- Per-line caching: Wrapped results cached and reused
- Smart invalidation: Cache properly invalidated on line insertion/deletion
- Benchmarks: 440ns rendering vs 1.4ms (old approach)
- Memory efficient: 1KB per render vs 1.7MB (99.94% reduction)
- Tested: Handles 10,000 line documents with zero lag
- Comprehensive logging: All operations logged to
debug.log - Cross-platform: Logs stored in standard config directories
- Linux:
~/.config/tuiwrite/debug.log - macOS:
~/Library/Application Support/tuiwrite/debug.log - Windows:
%APPDATA%\tuiwrite\debug.log
- Linux:
- Timestamped: Millisecond-precision timestamps for debugging
- Event tracking: Mode changes, commands, file ops, errors
- See LOGGING.md for details
go build -o tuiwrite# Create/open a story document
./tuiwrite mynovel.md
# Create/open a screenplay document
./tuiwrite myscript.fountain -mode scriptF1- Toggle file tree sidebarCtrl+S- Save fileCtrl+C/Ctrl+Q- QuitInsert- Toggle to Edit Mode (from Read) or Enter Edit ModeEsc- Switch to Read Mode (from Edit)
ββββorhjkl- Navigate cursor (visible but read-only)PgUp/PgDn- Scroll by pageCtrl+Home/g- Jump to document startCtrl+End/G- Jump to document endHome- Start of lineEnd- End of line:- Enter command mode
ββββ- Navigate cursorEnter- New lineBackspace- Delete character before cursor / Join with previous lineDelete- Delete character at cursor / Join with next lineHome- Start of lineEnd- End of line- Any printable character - Insert at cursor
ββorjk- Navigate up/down in file treeEnter- Expand/collapse folders, or select filesF1- Close file tree and return to editor
Press : in Read Mode to enter command mode. Available commands:
:spellcheckor:spell- Toggle spell checking on/off:spellcheck -ukor:spell -uk- Enable UK English spell-check (default):spellcheck -us- Enable US English spell-check:spellcheck -ca- Enable Canadian English:spellcheck -au- Enable Australian English:spellcheck -es- Enable Spanish:spellcheck -fr- Enable French:spellcheck -de- Enable German:spellcheck -it- Enable Italian:spellcheck -pt- Enable Portuguese
Note: Dictionaries are downloaded automatically on first use and cached in ~/.config/tuiwrite/dictionaries/
:wor:write- Save file:qor:quit- Quit application:wq- Save and quit
Press Esc to exit command mode.
The status bar shows:
- Current mode (READ or EDIT)
- Filename and modified indicator [+]
- Current line and column position
- Status messages (saves, errors, downloads)
- Command buffer (when in command mode)
- Quick help text
TUIWrite includes built-in spell-checking powered by Hunspell dictionaries:
- On-demand downloads: Dictionaries are automatically downloaded when you first select a language
- Multiple languages: Support for 10 languages (see command mode above)
- Lightweight: Only downloads dictionaries you actually use
- Cached locally: Dictionaries are stored locally for offline use (see paths below)
- Dictionary source: https://github.com/adam85sims/tuiwritedics
- Internet required: First-time dictionary downloads require internet connectivity
Dictionaries are cached in platform-specific locations:
- Linux/Unix:
~/.config/tuiwrite/dictionaries/ - macOS:
~/Library/Application Support/tuiwrite/dictionaries/ - Windows:
%APPDATA%\tuiwrite\dictionaries\
Once downloaded, dictionaries work offline. If you're not connected to the internet when trying to download a new dictionary, you'll receive an error message asking you to connect and try again.
Visual spell-check indicators (underlining misspelled words) will be added in a future update.
- β Rendering issue on line insertion: Fixed cache invalidation when inserting/deleting lines. The wrap cache is now properly invalidated for all lines after insertion/deletion points, preventing text from appearing to overlap.
- β File tree scrolling: Added viewport scrolling to the file tree sidebar. The tree now automatically scrolls to keep the selected item visible when navigating with arrow keys.
The following features from the design document are planned for future versions:
- F2-F4 function keys (statistics panel, search, main menu)
- Multi-file editing with tabs
- Visual spell-check highlighting (red underlines)
- Formatting commands (#bold:, #italics:, etc.)
- Structural commands (#title:, #chapter:, #break:, etc.)
- Chapter navigation system
- Statistics panel (word count, reading time, etc.)
- Search/find functionality
- Export functionality (Markdown, PDF, Fountain, etc.)
- Screenplay-specific formatting
- Undo/redo functionality
- Cut/copy/paste
- Theme customization
This editor focuses on a distraction-free modal editing experience for prose and screenplay writing. The application starts in Read Mode by default to prevent accidental edits. Performance is optimized for large documents through lazy word wrapping and intelligent caching.
For detailed implementation notes and architecture documentation, see CONTEXT.md.