This is a small experiment of writing a minimalist visual editor in Perl.
The minified Perl script is 1400 bytes. It runs on perl 5.36 (Debian's
perl-base
) and requires the stty
and tput
utilities as well as an
interactive bash
compiled with Readline support (all of these are Essential
in Debian).
Run it with a list of file names to edit in sequence. All editor commands act
on whole lines; to edit individual lines use the e
command which will use
bash's readline support to edit this line. There is a clipboard and a "hint
string" available which are kept across edited files. The "hint string" is sent
to Readline before editing the line so you can use readline's clipboard to move
parts of it into the actual line.
j
: move cursor downk
: move cursor upv
: toggle visual mode (in visual mode you can mark lines to act on)ZZ
: Save and continue editing the next fileQQ
: Discard changes and continue editing the next file:
: Run a Perl command with$_
bound to the current line (in a loop in case of visual mode)d
: Delete line(s) and place into clipboardy
: Copy line(s) to clipboardh
: append line(s) to hint stringJ
: Join two lines (or more in visual mode) using spaces
@
: Run a Perl command with@_
bound to the selected lines
o
: Open empty line below cursorO
: Open empty line above cursore
: Edit current line in ReadlineS
: Split current line; press repeatedly to decide split pointp
: Paste clipboard below cursorP
: Paste clipboard above cursor