Kibi: A text editor in ≤1024 lines of code, written in Rust
A configurable text editor with UTF-8 support, incremental search, syntax highlighting, line numbers and more, written in less than 1024 lines[^1] of Rust with minimal dependencies.
[^1]: Counted per platform, excluding tests and Clippy directives, see count_loc
Kibi is compatible with Linux, macOS, Windows 10[^2], and WASI.
[^2]: Kibi requires the terminal to support ANSI escape sequences. Windows 10 version 1703 (Creators Update, April 2017) and above are supported.
This project is inspired by kilo, a text
editor written in C.
See comparison below for a list of additional features.
Contributions are welcome! Be careful to stay below the 1024-line limit...
Table of contents
Installation
With cargo
You can install Kibi with cargo:
Syntax highlighting configuration files are available in the
syntax.d directory of this repository. They need to be placed in
one of the configuration directories mentioned in the
Configuration/Syntax Highlighting section.
For instance:
Arch User Repository (Arch Linux)
3 packages are available on the AUR:
kibi and
kibi-bin.
kibi-git.
-
Installation with an AUR helper, for instance using
paru: -
Install manually with
makepkg:
-
Installation with an AUR helper, for instance using
paru: -
Install manually with
makepkg:
-
Installation with an AUR helper, for instance using
paru: -
Install manually with
makepkg:
Android (with Termux)
Kibi is available as a Termux package.
Fedora/CentOS
The package is available in COPR as atim/kibi.
NetBSD
Kibi is available from the official repos.
Install using:
or build from source:
Flatpak
Kibi is available on Flathub.
You can then run Kibi with:
Usage
Keyboard shortcuts
| Keyboard shortcut | Description |
|---|---|
| Ctrl + F | Incremental search; use arrows to navigate |
| Ctrl + S | Save the buffer to the current file, or specify the file path |
| Ctrl + G | Go to <line number>[:<column number>] position |
| Ctrl + Q | Quit |
| Ctrl + D | Duplicate the current row |
| Ctrl + E | Execute an external command and paste its output |
| Ctrl + R | Remove an entire line |
| Ctrl + C | Copies the entire line |
| Ctrl + X | Cuts the entire line |
| Ctrl + V | Will paste the copied line |
| Ctrl + ← | Moves cursor to previous word |
| Ctrl + → | Moves cursor to next word |
| Ctrl + / | Comment or uncomment the current line |
Configuration
Global configuration
Kibi can be configured using a configuration file. It must follow this format:
# The size of a tab. Must be > 0.
tab_stop=4
# The number of confirmations needed before quitting, when changes have been
# made since the file was last changed.
quit_times=2
# The duration for which messages are shown in the status bar, in seconds.
message_duration=3
# Whether to show line numbers.
show_line_numbers=true
The location of these files is described below.
Linux / macOS
kibi follows the XDG Base Directory Specification:
- A user-level configuration file can be located at
$XDG_CONFIG_HOME/kibi/config.iniif environment variable$XDG_CONFIG_HOMEis defined,~/.config/kibi/config.iniotherwise. - A system-wide configuration file can be located at
$XDG_CONFIG_DIRS/kibi/config.iniif environment variable$XDG_CONFIG_DIRSis defined,/etc/kibi/config.inior/etc/xdg/kibi/config.iniotherwise.
Windows
A configuration file can be located at %APPDATA%\Kibi\config.ini.
Syntax highlighting
Syntax highlighting can be configured using INI files which follow this format:
### /usr/share/kibi/syntax.d/rust.ini ###
# Kibi syntax highlighting configuration for Rust
name=Rust
extensions=rs
highlight_numbers=true
singleline_string_quotes="
singleline_comment_start=//
multiline_comment_delims=/*, */
; In Rust, the multi-line string delimiter is the same as the single-line string
; delimiter
multiline_string_delim="
; https://doc.rust-lang.org/book/appendix-01-keywords.html
keywords_1=abstract, as, async, await, become, box, break, const, continue, crate, do, dyn, else, enum, extern, false, final, fn, for, if, impl, in, let, loop, macro, match, mod, move, mut, override, priv, pub, ref, return, self, Self, static, struct, super, trait, true, try, type, typeof, unsafe, unsized, use, virtual, where, while, yield
keywords_2=i8, i16, i32, i64, i128, isize, u8, u16, u32, u36, u128, usize, f32, f64, bool, char, str
The location of these files is described below.
Linux / macOS
kibi follows the XDG Base Directory Specification:
- User-level syntax highlighting configuration files can be located at
$XDG_DATA_HOME/kibi/syntax.d/<file_name>.iniif environment variable$XDG_DATA_HOMEis defined,~/.local/share/kibi/syntax.d/<file_name>.iniotherwise. - System-wide syntax highlighting configuration files can be located at
$XDG_DATA_DIRS/kibi/syntax.d/<file_name>.iniif environment variable$XDG_DATA_DIRSis defined,/usr/local/share/kibi/syntax.d/<file_name>.inior/usr/share/kibi/syntax.d/<file_name>.iniotherwise.
Windows
Syntax highlighting configuration files can be located at %APPDATA%\Kibi\syntax.d\<file_name>.ini.
Comparison with kilo
This project is inspired by kilo, a text
editor written by Salvatore Sanfilippo (antirez) in C, and
this tutorial (also in C).
kibi provides additional features:
- Support for UTF-8 characters
- Compatibility with Windows
- Command to jump to a given row/column
- Handle window resize (UNIX only)
- Parsing configuration files: global editor configuration with validation, language-specific syntax highlighting configuration (38 languages and counting)
- Display line numbers on the left of the screen; display file size in the status bar
- Syntax highlighting: multi-line strings
- Save as prompt when no file name has been provided
- Command to duplicate the current row, to quickly move between words
- Ability to execute an external command from the editor and paste its output
- Support for end-of-options delimiter
--(following POSIX.1-2024 12. Utility Conventions) - Can be used as the editor for the
sudoersfile viavisudo - Guaranteed memory safety, thanks to Rust!
- Bug fixes
Contributing
Contributions of any kind are welcome! Make sure to check out the contributing guide:
CONTRIBUTING.md.
Dependencies
This project must remain tiny, so using advanced dependencies such as ncurses,
toml or
ansi-escapes would be cheating.
The following dependencies provide wrappers around system calls.
- On UNIX systems (Linux, macOS):
libc
- On Windows:
winapiwinapi-util
In addition, unicode-width is used to determine the displayed width of Unicode
characters. Unfortunately, there is no way around it: the
unicode character width table
is 230 lines long.
Why Kibi?
- Porting the
kilosource code from C to Rust and trying to make it idiomatic was interesting - Implementing new features while under the 1024-line constraint is a good challenge
- Most importantly, I wanted to learn Rust and this was a great project to start (thanks Reddit for the idea)
Contributors
This project follows the all-contributors specification (emoji key). Contributions of any kind welcome!
License
This project is licensed under either of
at your option.

