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 mode | Action |
|---|---|
| i a o O | insert at or after the cursor; open a line below or above |
| h j k l, arrows, 0 $ g G | move; start and end of line; first and last line |
| Ctrl-F Ctrl-B, PageDown, PageUp | page down and up |
| / ? n N | search forward and backward, next and previous match |
| x p J | delete a character, paste, join lines |
| ← → | previous and next buffer (in normal mode) |
| Command | Action |
|---|---|
:w, :w name, :q, :q!, :wq, :x | save, save as, quit, force quit, save and quit |
:N | go to line N |
:set nu / nonu, :set wrap / nowrap | line numbers and soft wrapping (both on by default) |
:e file, :ls, :bn, :bp, :b N, :b name, :bd | open 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/.