A tiny, configurable kibi-based modal text editor with UTF-8 support, incremental search, syntax highlighting, line numbers and more.
You can install Kime with cargo
:
$ cargo install kime
Syntax highlighting configuration files are available in the config_example/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/NoraCodes/kime.git
$ mkdir -p ~/.config/kime
$ ln -sr ./kime/syntax ~/.config/kime/syntax.d
# Start an new text buffer
$ kime
# Open a file
$ kime <file path>
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 |
Kime can be configured using:
- A system-wide configuration file, located at
/etc/kime/config.ini
- A user-level configuration file, located at:
$XDG_CONFIG_HOME/kime/config.ini
if environment variable$XDG_CONFIG_HOME
is defined~/.config/kime/config.ini
otherwise
Example configuration file:
# 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
Syntax highlighting can be configured using INI files located at:
/etc/kime/syntax.d/<file_name>.ini
for system-wide availability- For user-level configuration files:
$XDG_CONFIG_HOME/kime/syntax.d/<file_name>.ini
if environment variable$XDG_CONFIG_HOME
is defined~/.config/kime/syntax.d/<file_name>.ini
otherwise
Kime is compatible with kibi syntax highlighting files and will fall back to the kibi locations if highlighting files are not found in the kime locations.
Syntax highlighting configuration follows this format:
### /etc/kime/syntax.d/rust.ini ###
# Kime syntax highlighting configuration for Rust
name=Rust
extensions=rs
highlight_numbers=true
highlight_strings=true
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
This project is built on top of kibi
, adding the following features:
- nothing, yet.
kibi
was inspired by kilo
, a text editor written by Salvatore Sanfilippo
(antirez) in C, and this tutorial (also in C).
kime
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. Unfortunately, there is no
way around it: the unicode character width table
is 230 lines long.
- Porting the
kilo
source 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)
Kime 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.