Skip to content

Line Editor

Kyler Clay edited this page Aug 24, 2026 · 2 revisions

Line Editor

shed's line editor is a modal text editor written from scratch, based on vim. It can operate in both vi-like and emacs-like modes, per POSIX. shed's line editor puts a strong focus on making multi-line editing a first-class aspect of writing commands.

Modes

Emacs Mode

The default mode. Supports the usual bash readline-style keybindings (Ctrl+A/Ctrl+E/Ctrl+W, transposition, kill ring, etc.), with multi-line awareness layered on top.

ex mode can be accessed using Alt+;

Vi Mode

Enable with shopt set.vi=true or set -o vi. Implements normal, insert, visual, and replace modes with wide coverage of the standard vi motions and operators, including several vim-specific extensions like g?, and also implements registers and macro recording.

: from normal mode enters ex mode.

Ex Mode

A secondary command prompt that has many tools for both controlling the line editor, and executing shell commands without losing the one you are currently working on.

A full list of ex mode commands and more can be found here.

Editing files

:r <file> allows you to read a file into the buffer, and :w <file> allows you to write the buffer to a file. This allows for fast iteration when writing shed scripts; since multi-line editing is first class, you can easily write and test the entire script in the repl, without having to jump between an editor and a shell. Once it is working as expected, write it to a file for later use.

Quirks

shed's line editor by default does its best to reconcile the meaning of certain keys based on the position of the cursor. Since the line editor is essentially a text editor and is meant to be used like one, Enter and Tab mean different things depending on where the cursor is.

If the current line up to the current cursor position would be considered "incomplete input", e.g. the cursor is inside of quotes or braces, Enter will break a new line. Otherwise, Enter will submit the entire buffer to be executed.

If the cursor is at the start of a line, Tab will indent the current line. Otherwise, it will attempt tab-completion. "The start of a line" basically just means "there are no visible characters on the left side of the cursor".

Clone this wiki locally