Kilo is a minimal text editor written in C, designed to be simple yet functional. It provides basic text editing capabilities with a terminal-based interface.
- Basic text editing operations (insert, delete, move cursor)
- File I/O operations (open, save)
- Search functionality
- Terminal-based UI with status bar
- Support for tabs and special characters
- Scrolling support for large files
- Unsaved changes protection
The codebase is organized into several key sections:
- Standard C library includes for basic functionality
- Custom defines for editor configuration
- Special key codes for editor navigation
erow: Represents a row in the editor- Stores both raw characters and rendered characters (with tabs expanded)
- Maintains size information for both raw and rendered content
editorConfig: Global editor configuration- Cursor position and screen dimensions
- File information and status
- Terminal settings
- Raw mode handling for direct terminal input
- Terminal size detection
- Cursor position management
- Error handling
- Row manipulation (insert, delete, update)
- Tab handling and rendering
- Position conversion between cursor and render coordinates
- File opening and saving
- String conversion for file operations
- Error handling for file operations
- Text search with navigation
- Search result highlighting
- Directional search support
- Screen rendering
- Status bar and message display
- Scrolling implementation
- Cursor positioning
- Key press processing
- Special key handling
- Command processing
Ctrl-S: Save fileCtrl-Q: Quit editor (requires multiple presses if there are unsaved changes)Ctrl-F: Search in file- Arrow keys: Navigate
Home/End: Move to start/end of linePage Up/Down: Scroll up/down
Build the editor:
makeBuilding without make, C23 can be replaced with your version of C
cc kilo.c -o kilo -Wall -Wextra -pedantic -std=c23To run the editor with an existing file:
./kilo [filename]Or to run the editor without any input file
./kilo The editor requires a POSIX-compliant system with the following headers:
termios.hsys/ioctl.hunistd.h
This project is based on Salvatore Sanfilippo's (antirez) Kilo - A Text Editor in 1000 lines of C code. An excellent tutorial for this project was made by Jeremy Ruten (snaptoken) here.
The original project by Salvatore Sanfilippo (antirez) and the tutorial by Jeremy Ruten (snaptoken) are both licensed under the BSD 2-Clause License. This repository is also licensed under the BSD 2-Clause License.