A text editor in ≤1024 lines of code, written in Rust

Overview

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

Build Status Crate Minimum rustc version Platform Packaging status License Gitpod Ready-to-Code All Contributors

asciicast

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.

Kibi is compatible with Linux, macOS, and Windows 102.

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

1.: Counted with count_loc.sh
2.: Kibi requires the terminal to support ANSI escape sequences. Windows 10 version 1703 (Creators Update, April 2017) and above are supported.

Table of contents

Installation

Packaging status

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.

Installation instructions
  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

Android (with Termux)

Kibi is available as a Termux package.

Installation instructions
  1. Install Termux:

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

  2. Install Kibi within Termux: pkg install kibi

Fedora/CentOS

The package is available in COPR as atim/kibi.

Installation instructions
sudo dnf copr enable atim/kibi -y
sudo dnf install kibi

NetBSD

Kibi is available from the official repos.

Installation instructions

Install using:

pkgin install kibi

or build from source:

cd /usr/pkgsrc/editors/kibi
make install

Usage

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

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

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.ini if environment variable $XDG_CONFIG_HOME is defined, ~/.config/kibi/config.ini otherwise.
  • A system-wide configuration file can be located at $XDG_CONFIG_DIRS/kibi/config.ini if environment variable $XDG_CONFIG_DIRS is defined, /etc/kibi/config.ini or /etc/xdg/kibi/config.ini otherwise.
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>.ini if environment variable $XDG_DATA_HOME is defined, ~/.local/share/kibi/syntax.d/<file_name>.ini otherwise.
  • System-wide syntax highlighting configuration files can be located at $XDG_DATA_DIRS/kibi/syntax.d/<file_name>.ini if environment variable $XDG_DATA_DIRS is defined, /usr/local/share/kibi/syntax.d/<file_name>.ini or /usr/share/kibi/syntax.d/<file_name>.ini otherwise.
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, 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
  • Ability to execute an external command from the editor and paste its output
  • Memory safety, thanks to Rust!
  • Many bug fixes

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:
    • winapi
    • winapi-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?

  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!


Ilaï Deutel

💻 🤔 🚇 📦 💠

Vishal Anand

🐛

Gurjus Bhasin

🤔

Libin Dang

💻 🐛

Isaac Andrade

🤔

frjol

🐛

Artem Polishchuk

📦

Marco A L Barbosa

💻

pin

📦

Uniminin

💠

Woomy4680-exe

🐛

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.

Comments
Releases(v0.2.2)
Owner
Ilaï Deutel
Ilaï Deutel
A terminal-based text editor written in Rust

Iota Iota is a terminal-based text-editor written in Rust. Here's what it looks like right now, editing itself. Motivation Iota was born out of my fru

Greg Chapple 1.6k Jan 8, 2023
Web base text editor written in rust

Ultron Ultron is a web based monospace text-editor with syntax highlighting, completely written in rust. I wrote this code editor for my very specific

Jovansonlee Cesar 59 Aug 8, 2022
TIF is a terminal_image_format. (theres no TIF editor, so i made TIF images through a hex editor lol)

Colors these are the colors you can use when displaying images on the terminal BYTES: 5A = BLUE 5B = BLACK 5C = RED 5D = GREEN 5E = PURPLE 5F = WHITE

buzz 5 Dec 23, 2022
An independent Rust text editor that runs in your terminal!

Ox editor Ox is a code editor that runs in your terminal. About The Project Ox is a code editor. It was written in Rust using ANSI escape sequences. I

null 2.9k Jan 2, 2023
Ginkgo is a text editor built entirely in Rust

Ginkgo is a text editor built entirely in Rust. It supports cursor movements, CTRL commands, select vim commands, insert vs. normal modes, and more. Ginkgo is based on my text editor JED, which itself was based on the popular online editor Kilo.

James Asbury 12 Oct 15, 2022
Aspiring vim-like text editor

Rim Rim is an aspiring Vim-like text editor written in Rust. Current state Rim is in an early prototype stage. This means that you can load, edit and

Mathias Hällman 557 Jan 2, 2023
An experimental next-generation Electron-based text editor

Attention: GitHub has decided not to move forward with any aspect of this project. We'll archive the repository in case anybody finds value here, but

Atom Archive 8.5k Dec 26, 2022
ReVi is a cross-platform terminal based Vim inspired text editor.

ReVi Table Of Contents: About Usage Install Clone && Installing Development Q&A KeyBindings Roadmap Changelog About ReVi is a cross-platform terminal

null 31 Sep 21, 2022
Archeum - a minimalist text editor

Archeum About The Project Archeum is a minimalist text editor that is really usefull if you've been in the vim psychosis for to long. Reject plugins,

null 4 Jul 1, 2022
(An attempt to write) a modal text editor

kaka (An attempt to write) a modal text editor. NOTE: The project is very young and certainly not ready for use. Current project goals keymap and mode

Marcin Pajkowski 4 Aug 15, 2022
Lightning-fast and Powerful Code Editor written in Rust

Lapce Lightning-fast and Powerful Code Editor written in Rust About Lapce is written in pure Rust, with UI in Druid. It's using Xi-Editor's Rope Scien

Lapce 22.1k Jan 8, 2023
My own personal code editor built with Rust + OpenGL

Glyph This is my personal code editor that I am building for fun and to get more familiar with OpenGL. Glyph currently supports Vim keybinds, syntax h

Zack Radisic 83 Dec 23, 2022
An opinionated modal editor to simplify code editing from the terminal

(I'm currently refactoring the platform layer. So we have to first finish this cleanup before we're able to continue adding features) An opinionated m

Matheus Lessa Rodrigues 284 Jan 5, 2023
Rustpad is an efficient and minimal collaborative code editor, self-hosted, no database required

Rustpad is an efficient and minimal open-source collaborative text editor based on the operational transformation algorithm

Eric Zhang 2.5k Dec 31, 2022
A package manager for the Lite-XL code editor

Lite-XL Package Manager (lpm) (Under Development) lpm is an attempt to create a package manager for the Lite-XL code editor. It's primary goal is to p

Debarchito Nath 12 Dec 11, 2022
A modern editor with a backend written in Rust.

Xi Editor (pronounced "Zigh") A modern editor with a backend written in Rust. Maintenance status: The xi-editor project is not currently under active

null 19.7k Jan 5, 2023
A collision editor for Guilty Gear -Strive-, written in Rust

ggst_collision_editor_rs A collision editor for Guilty Gear -Strive- and other Team Red Arc System Works games, written in Rust. Uses a customized ver

null 4 May 3, 2022
Helix - A kakoune / neovim inspired editor, written in Rust

A kakoune / neovim inspired editor, written in Rust. The editing model is very heavily based on kakoune; during development I found myself agree

null 17.9k Jan 10, 2023
A pathtracer written in rust - runs in the web and includes an editor

Webtracer A pathtracer written in rust - runs in the web and includes an editor Rendering is parallelized and utilizes all cpu cores You can easily ed

Shapur 5 Oct 7, 2022