Home

Awesome

Kibi: A text editor in ≀1024 lines of code, written in Rust

Build Status Lines of code Crate Minimum rustc version Platform Packaging status Dependency Status License Contributor Covenant Gitpod Ready-to-Code<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> All Contributors

<!-- ALL-CONTRIBUTORS-BADGE:END -->

asciicast

A configurable text editor with UTF-8 support, incremental search, syntax highlighting, line numbers and more, written in less than 1024 lines<sup>1</sup> of Rust with minimal dependencies.

Kibi is compatible with Linux, macOS, Windows 10<sup>2</sup>, and WASI.

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...

<!-- markdownlint-disable MD033 -->

<sub><a name="counted-with">1.</a>: Counted per platform, excluding tests and Clippy directives, see count_loc.sh</sub>
<sub><a name="windows-version">2.</a>: Kibi requires the terminal to support ANSI escape sequences. Windows 10 version 1703 (Creators Update, April 2017) and above are supported.</sub>

<!-- markdownlint-enable MD033 -->

Table of contents

Installation

<!-- markdownlint-disable MD033 --> <a href="https://repology.org/project/kibi/versions"> <img src="https://repology.org/badge/vertical-allrepos/kibi.svg" alt="Packaging status" align="right"> </a> <!-- markdownlint-enable MD033 -->

With cargo

You can install Kibi with cargo:

cargo install kibi

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:

cd ~/repos
git clone https://github.com/ilai-deutel/kibi.git
mkdir -p ~/.local/share/kibi/
ln -sr ./kibi/syntax.d ~/.local/share/kibi/syntax.d

Arch User Repository (Arch Linux)

2 packages are available on the AUR: kibi and kibi-git.

<details><summary>Installation instructions</summary>
  1. Installation with an AUR helper, for instance using yay:

    yay -Syu kibi  # or yay -Syu kibi-git
    
  2. Install manually with makepkg:

    git clone https://aur.archlinux.org/kibi.git  # or git clone https://aur.archlinux.org/kibi-git.git
    cd kibi
    makepkg -si
    
</details>

Android (with Termux)

Kibi is available as a Termux package.

<details><summary>Installation instructions</summary>
  1. Install Termux:

    Get it on F-Droid" Get it on Google Play"

  2. Install Kibi within Termux: pkg install kibi

</details>

Fedora/CentOS

The package is available in COPR as atim/kibi.

<details><summary>Installation instructions</summary>
sudo dnf copr enable atim/kibi -y
sudo dnf install kibi
</details>

NetBSD

Kibi is available from the official repos.

<details><summary>Installation instructions</summary>

Install using:

pkgin install kibi

or build from source:

cd /usr/pkgsrc/editors/kibi
make install
</details>

Flatpak

Kibi is available on Flathub.

<details><summary>Command line instructions</summary> The flatpak can be installed using:
flatpak install flathub com.github.ilai_deutel.kibi

You can then run Kibi with:

flatpak run com.github.ilai_deutel.kibi
</details>

Usage

kibi              # Start an new text buffer
kibi <file path>  # Open a file
kibi --version    # Print version information and exit

Keyboard shortcuts

Keyboard shortcutDescription
Ctrl-FIncremental search; use arrows to navigate
Ctrl-SSave the buffer to the current file, or specify the file path
Ctrl-GGo to <line number>[:<column number>] position
Ctrl-QQuit
Ctrl-DDuplicate the current row
Ctrl-EExecute an external command and paste its output
Ctrl-RRemove an entire line
Ctrl-CCopies the entire line
Ctrl-XCuts the entire line
Ctrl-VWill paste the copied line
Ctrl-LeftArrowMoves cursor to previous word
Ctrl-RightArrowMoves cursor to next word

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:

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:

<!-- markdownlint-disable MD013 -->
### /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
<!-- markdownlint-enable MD013 -->

The location of these files is described below.

Linux / macOS

kibi follows the XDG Base Directory Specification:

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:

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.

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?

  1. Porting the kilo source code from C to Rust and trying to make it idiomatic was interesting
  2. Implementing new features while under the 1024-line constraint is a good challenge
  3. 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!

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- prettier-ignore-start --> <!-- markdownlint-disable --> <table> <tbody> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/ilai-deutel"><img src="https://avatars0.githubusercontent.com/u/10098207?v=4" width="100px;" alt=""/><br /><sub><b>IlaΓ― Deutel</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/commits?author=ilai-deutel" title="Code">πŸ’»</a> <a href="#ideas-ilai-deutel" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="#infra-ilai-deutel" title="Infrastructure (Hosting, Build-Tools, etc)">πŸš‡</a> <a href="#platform-ilai-deutel" title="Packaging/porting to new platform">πŸ“¦</a> <a href="#syntax-highlighting-ilai-deutel" title="Contributing to syntax highlighting configuration files">πŸ’ </a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/codingonHP"><img src="https://avatars3.githubusercontent.com/u/7105293?v=4" width="100px;" alt=""/><br /><sub><b>Vishal Anand</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/issues?q=author%3AcodingonHP" title="Bug reports">πŸ›</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/gsbhasin123"><img src="https://avatars2.githubusercontent.com/u/48339289?v=4" width="100px;" alt=""/><br /><sub><b>Gurjus Bhasin</b></sub></a><br /><a href="#ideas-gsbhasin123" title="Ideas, Planning, & Feedback">πŸ€”</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/ldang0"><img src="https://avatars1.githubusercontent.com/u/1281722?v=4" width="100px;" alt=""/><br /><sub><b>Libin Dang</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/commits?author=ldang0" title="Code">πŸ’»</a> <a href="https://github.com/ilai-deutel/kibi/issues?q=author%3Aldang0" title="Bug reports">πŸ›</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/andradei"><img src="https://avatars0.githubusercontent.com/u/2653546?v=4" width="100px;" alt=""/><br /><sub><b>Isaac Andrade</b></sub></a><br /><a href="#ideas-andradei" title="Ideas, Planning, & Feedback">πŸ€”</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/frjol"><img src="https://avatars2.githubusercontent.com/u/4422813?v=4" width="100px;" alt=""/><br /><sub><b>frjol</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/issues?q=author%3Afrjol" title="Bug reports">πŸ›</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/tim77"><img src="https://avatars0.githubusercontent.com/u/5614476?v=4" width="100px;" alt=""/><br /><sub><b>Artem Polishchuk</b></sub></a><br /><a href="#platform-tim77" title="Packaging/porting to new platform">πŸ“¦</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/malbarbo"><img src="https://avatars3.githubusercontent.com/u/1678126?v=4" width="100px;" alt=""/><br /><sub><b>Marco A L Barbosa</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/commits?author=malbarbo" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/voidpin"><img src="https://avatars3.githubusercontent.com/u/35956139?v=4" width="100px;" alt=""/><br /><sub><b>pin</b></sub></a><br /><a href="#platform-voidpin" title="Packaging/porting to new platform">πŸ“¦</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/Uniminin"><img src="https://avatars3.githubusercontent.com/u/42061747?v=4" width="100px;" alt=""/><br /><sub><b>Uniminin</b></sub></a><br /><a href="#syntax-highlighting-Uniminin" title="Contributing to syntax highlighting configuration files">πŸ’ </a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/Woomy4680-exe"><img src="https://avatars.githubusercontent.com/u/57042741?v=4" width="100px;" alt=""/><br /><sub><b>Woomy4680-exe</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/issues?q=author%3AWoomy4680-exe" title="Bug reports">πŸ›</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/quadroli"><img src="https://avatars.githubusercontent.com/u/58091631?v=4" width="100px;" alt=""/><br /><sub><b>quadroli</b></sub></a><br /><a href="#syntax-highlighting-quadroli" title="Contributing to syntax highlighting configuration files">πŸ’ </a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/m0lese"><img src="https://avatars.githubusercontent.com/u/86180257?v=4" width="100px;" alt=""/><br /><sub><b>molese</b></sub></a><br /><a href="#syntax-highlighting-m0lese" title="Contributing to syntax highlighting configuration files">πŸ’ </a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/imreyesjorge"><img src="https://avatars.githubusercontent.com/u/40706868?v=4" width="100px;" alt=""/><br /><sub><b>Jorge Reyes</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/commits?author=imreyesjorge" title="Code">πŸ’»</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/gVirtu"><img src="https://avatars.githubusercontent.com/u/15658199?v=4" width="100px;" alt=""/><br /><sub><b>Giancarlo FranΓ§a</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/commits?author=gVirtu" title="Tests">⚠️</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/ilmanzo"><img src="https://avatars.githubusercontent.com/u/1872816?v=4" width="100px;" alt=""/><br /><sub><b>Andrea Manzini</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/commits?author=ilmanzo" title="Code">πŸ’»</a> <a href="https://github.com/ilai-deutel/kibi/commits?author=ilmanzo" title="Tests">⚠️</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/Arkaeriit"><img src="https://avatars.githubusercontent.com/u/47985708?v=4" width="100px;" alt=""/><br /><sub><b>Maxime Bouillot</b></sub></a><br /><a href="#syntax-highlighting-Arkaeriit" title="Contributing to syntax highlighting configuration files">πŸ’ </a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/john-sharratt"><img src="https://avatars.githubusercontent.com/u/17711537?v=4" width="100px;" alt=""/><br /><sub><b>Johnathan Sharratt</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/commits?author=john-sharratt" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/No-one-important"><img src="https://avatars.githubusercontent.com/u/72458263?v=4" width="100px;" alt=""/><br /><sub><b>No-one-important</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/commits?author=No-one-important" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/RobertGrancsa"><img src="https://avatars.githubusercontent.com/u/22158239?v=4" width="100px;" alt=""/><br /><sub><b>Robert Grancsa</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/commits?author=RobertGrancsa" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/sogreatandpowerfull"><img src="https://avatars.githubusercontent.com/u/114095654?v=4" width="100px;" alt=""/><br /><sub><b>SoGreatAndPowerful</b></sub></a><br /><a href="#syntax-highlighting-sogreatandpowerfull" title="Contributing to syntax highlighting configuration files">πŸ’ </a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/carol-mb"><img src="https://avatars.githubusercontent.com/u/117681554?v=4" width="100px;" alt=""/><br /><sub><b>Mihai-Carol Bazga</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/commits?author=carol-mb" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/NickGeek"><img src="https://avatars.githubusercontent.com/u/3462055?v=4" width="100px;" alt=""/><br /><sub><b>Nick Webster</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/commits?author=NickGeek" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/hezhizhen"><img src="https://avatars.githubusercontent.com/u/7611700?v=4" width="100px;" alt=""/><br /><sub><b>Zhizhen He</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/commits?author=hezhizhen" title="Documentation">πŸ“–</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/CosminGGeorgescu"><img src="https://avatars.githubusercontent.com/u/95082750?v=4" width="100px;" alt=""/><br /><sub><b>CosminGGeorgescu</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/commits?author=CosminGGeorgescu" title="Code">πŸ’»</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/TanvirOnGH"><img src="https://avatars.githubusercontent.com/u/138336161?v=4" width="100px;" alt=""/><br /><sub><b>Tanvir</b></sub></a><br /><a href="#syntax-highlighting-TanvirOnGH" title="Contributing to syntax highlighting configuration files">πŸ’ </a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/BogdanPaul15"><img src="https://avatars.githubusercontent.com/u/62438221?v=4" width="100px;" alt=""/><br /><sub><b>Prisacaru Bogdan-Paul</b></sub></a><br /><a href="https://github.com/ilai-deutel/kibi/commits?author=BogdanPaul15" title="Tests">⚠️</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/auzkok"><img src="https://avatars.githubusercontent.com/u/35302680?v=4" width="100px;" alt=""/><br /><sub><b>auzkok</b></sub></a><br /><a href="#syntax-highlighting-auzkok" title="Contributing to syntax highlighting configuration files">πŸ’ </a></td> </tr> </tbody> </table> <!-- markdownlint-restore --> <!-- prettier-ignore-end --> <!-- ALL-CONTRIBUTORS-LIST:END -->

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Kibi by you shall be dual licensed as above, without any additional terms or conditions.