A code editor in the terminal (in 1600 lines of code)
I created rilo because i've seen this guide : kilo but it was in C and with some little functionality i didn't really like (like the PageUp/PageDown thing), so i recreated it in rust with a lot of new functionality.
![]() C code (rilo) |
![]() C code (vim) |
|||
![]() Home screen (rilo) |
![]() Home screen (vim) |
|||
![]() Message |
||||
- Auto-indent
- Auto-close:
([{"'insert their closing character, typing the closing character steps over it and Backspace between a pair deletes both - Toggle comment (
Ctrl-K): adds/removes the single-line comment of the current language (//or#) - Go to line (
Ctrl-G) - Search with match highlighting
- Save and Save as
- Command prompt (
Ctrl-P): see Commands
- Line numbers: the current line is brighter, can be removed with
~/.rilorc - Highlight syntax with the same colors as vim
- Supported languages: C/C++ (
.c.h.cpp), Rust (.rs) and Python (.py) - Hexadecimal number support
#defineand#includesupport (in C)
- Supported languages: C/C++ (
- Message bar: can show Warning, Error, Help and Info (with color !)
- Every message is gone after 3 sec
- Status bar: show the filename, the total number of lines, the filetype (for highlighting) and the current line
- (modified) flag when there are unsaved changes + warning when quitting with unsaved changes
- Welcome screen: with the version, GitHub link and keybinds
- Uses
queue!()(from crossterm) for less/no flicker
~/.rilorc: you can change different settings likeTAB_STOP,QUIT_TIMES,AUTO_INDENTandSHOW_LINES_NUMBER- Read from stdin:
cat file | rilo - - Open at a line:
rilo file.rs +42 - New files:
rilo newfile.txtopens an empty buffer and you can save it with that name withCtrl-S
In it you can change different settings of the editor. I built a custom parser to get those settings into the editor.
Here is an example (these are the default values):
TAB_STOP=4
QUIT_TIMES=1
SHOW_LINES_NUMBER=true
AUTO_INDENT=true
| Option | Values | Description |
|---|---|---|
TAB_STOP |
number | Width of a tab |
QUIT_TIMES |
number | How many extra Ctrl-C presses are needed to quit with unsaved changes (default 1, so two presses in total) |
SHOW_LINES_NUMBER |
true / false |
Show the line numbers on the left |
AUTO_INDENT |
true / false |
Keep the indentation on a new line |
# at the start of a line comments the option out
You can re-read the file without restarting with the reload command.
| Key | Action |
|---|---|
| Arrow | Move around |
| Ctrl-A / Ctrl-D | Go to start / end of line |
| Ctrl-W / Ctrl-X | Page up / page down |
| Ctrl-S | Save |
| Ctrl-Shift-S* (or Ctrl-O) | Save as... |
| Ctrl-F | Search |
| Down/Right (when search) | Go to the next occurrence |
| Up/Left (when search) | Go to the previous occurrence |
| Ctrl-G | Go to line |
| Ctrl-K | Toggle comment on the current line |
| Ctrl-P | Open the command prompt |
| Esc | Quit prompt / clear search |
| Ctrl-C | Quit |
You can press Ctrl-P to access the command prompt and enter a command
| Command | Action |
|---|---|
save (or w) |
Save |
saveas |
Save as... (asks for the name) |
goto N |
Go to line N |
set number on / set number off |
Show / hide the line numbers |
set syntax NAME |
Force the highlighting: c, rust, python or none (useful for piped text) |
reload |
Re-read ~/.rilorc |
version |
Show the version |
The easiest way to get rilo is to run :
cargo install riloto get the latest version ( ദ്ദി ˙ᗜ˙ ). (Otherwise you can build the project from source on your own here: Development)
ദ്ദി(˵ •̀ ᴗ - ˵ ) ✧
rilo file.c # open a file (or start a new one if it doesn't exist)
rilo file.c +42 # open a file at line 42
rilo # empty buffer
cat file | rilo - # read the text from stdin
rilo --help # show the usage
rilo --version # show the version- Clone the repository with
git clone https://github.com/wirenux/rilo.git
cd rilo- Then install the dependencies and run the program with:
cargo run
# or open a file
cargo run -- file.rsI used AI only to generate test code in C, Python and Rust, to test the highlighting of the syntax. All generated code are in the test/ folder.
And when i was stuck on understanding complex C code.
Everything else is built on my own.
This project is created by @wirenux in Rust, using crossterm.
Logo created by @wirenux (using Photopea)
This project is released under the MIT License
Idea came from: kilo
Ctrl-Shift-S might not work in some terminal. If so, you can use Ctrl-O





