A configurable text editor with UTF-8 support, incremental search, syntax highlighting, line numbers and more, written in less than 1024 lines1 of Rust with minimal dependencies.
This project is inspired by kilo
, a text editor written in C. See comparison below.
Contributions are welcome! Be careful to stay below the 1024-line limit...
cargo
You can install Kibi with cargo
:
bash
$ cargo install kibi
Syntax highlighting configuration files are available in the syntax
directory of this repository.
They need to be placed in one of the configuration directories mentioned in the Configuration/Syntax Highlighting section.
For instance:
bash
$ cd ~/repos
$ git clone https://github.com/ilai-deutel/kibi.git
$ mkdir -p ~/.config/kibi
$ ln -sr ./kibi/syntax ~/.config/kibi/syntax.d
kibi
is available on the AUR.
For instance, using yay
:
bash
yay -Syu kibi
makepkg
bash
git clone https://aur.archlinux.org/kibi.git
cd kibi
makepkg -si
```bash
$ kibi
$ kibi
| 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 |
Kibi can be configured using:
* A system-wide configuration file, located at /etc/kibi/config.ini
* A user-level configuration file, located at:
* $XDG_CONFIG_HOME/kibi/config.ini
if environment variable $XDG_CONFIG_HOME
is defined
* ~/.config/kibi/config.ini
otherwise
Example configuration file: ```ini
tab_stop=4
quit_times=2
message_duration=3
showlinenumbers=true ```
Syntax highlighting can be configured using INI files located at:
* /etc/kibi/syntax.d/<file_name>.ini
for system-wide availability
* For user-level configuration files:
* $XDG_CONFIG_HOME/kibi/syntax.d/<file_name>.ini
if environment variable $XDG_CONFIG_HOME
is defined
* ~/.config/kibi/syntax.d/<file_name>.ini
otherwise
Syntax highlighting configuration follows this format:
```ini
name=Rust extensions=rs highlightnumbers=true highlightstrings=true singlelinecommentstart=// multilinecommentdelim=/*, */ ; The keyword list is taken from here: https://doc.rust-lang.org/book/appendix-01-keywords.html keywords1=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 keywords2=i8, i16, i32, i64, i128, isize, u8, u16, u32, u36, u128, usize, f32, f64, bool, char, str ```
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
- Command to jump to a given row/column
- Handle window resize
- Parsing configuration files: global editor configuration, language-specific syntax highlighting configuration
- 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
- Memory safety, thanks to Rust!
- Many bug fixes
This project must remain tiny, so using advanced dependencies such as ncurses
, toml
or ansi-escapes
would be cheating.
These dependencies provide safe wrappers around libc
calls, to avoid using unsafe
code as much as possible:
libc
nix
signal-hook
In addition, unicode-width
is used to determine the displayed width of Unicode characters.
kilo
source code from C to Rust and trying to make it idiomatic was interestingKibi is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT, and COPYRIGHT for details.