MMotor OS
Userspace

Editors

Two editors ship in /user/bin: red, which behaves like vi and is on every image, and kibim, a small kilo-style editor on the standard and developer images.

red

red is a terminal editor written from scratch with only the Rust standard library: no crossterm, no libc. It renders each frame into an in-memory grid of cells and diffs it against the previous frame, so typing rewrites only the edited line from the first changed column and a cursor move rewrites only the digits in the status bar. It runs in the alternate screen, restores the terminal on exit and on panic, decodes UTF-8, renders tabs at configurable stops, and writes files with POSIX line termination (a file that had no final newline gains one; an untouched file saves byte-for-byte identical).

Modes and keys

Five modes, as in vim: NORMAL, INSERT, VISUAL (v), VISUAL LINE (V), and COMMAND (:).

Normal modeAction
i a o Oinsert at or after the cursor; open a line below or above
h j k l, arrows, 0 $ g Gmove; start and end of line; first and last line
Ctrl-F Ctrl-B, PageDown, PageUppage down and up
/ ? n Nsearch forward and backward, next and previous match
x p Jdelete a character, paste, join lines
previous and next buffer (in normal mode)
CommandAction
:w, :w name, :q, :q!, :wq, :xsave, save as, quit, force quit, save and quit
:Ngo to line N
:set nu / nonu, :set wrap / nowrapline numbers and soft wrapping (both on by default)
:e file, :ls, :bn, :bp, :b N, :b name, :bdopen a file in a new buffer, list buffers, switch, close (add ! to discard changes)

In visual modes, y yanks and d, x, or Delete cuts the selection; the normal-mode motions extend it. Insert mode has Backspace, Delete, Enter, Tab (spaces to the next tab stop unless expandtab is off), and arrows.

Configuration and highlighting

red reads an optional /user/cfg/red.toml ($HOME/.config/red.toml on Linux) with two options named after their vim equivalents: tabstop (default 4) and expandtab (default true). Syntax highlighting is incremental and cascades block state (a multi-line comment) down only as far as it changes, for Rust, Bash, C and C++, and TOML.

On Motor OS red gets its size from the terminal-size protocol described under Terminals, so it lays itself out correctly on the console, in an SSH session, and in an rmux pane, and repaints when the size changes.

kibim

kibim is Motor OS's build of kibi, a small editor in the tradition of kilo: modeless editing with a status bar, incremental search, and syntax highlighting defined by INI files. The highlighting definitions for about thirty languages live under /user/cfg/kibim/syntax.d/, and the editor's own settings in /user/cfg/kibim/.