
Primary Repository https://codeberg.org/SirWumpus/eh
eh - Edit Here - vi(1) the good parts version
eh [filename]
A minimalist version of vi(1). It is an example of the "Buffer Gap" method outlined in the The Craft Of Text Editing used by many Emacs style editors. (Yep I mixed vi and emacs in the same paragraph; I'm going to hell for that one.)
Create or read a text file to edit. Text files consists of lines of printable UTF-8 text, tabs, or newline characters. A physical line can be of arbitrary length and is delimited by either a newline or the end of file. Tab stops are every eight columns. The behaviour of non-printable characters may vary depending on the implementation of the Curses library, stty(1) settings, or terminal emulator.
The commands are similar, but not the same as vi(1). Most commands can be prefixed by a repeat count, eg. 5w, 123G, 2dw (d2w), or 2d3w (d6w). Motion commands, optionally prefixed by a count, are those that move the cursor without modifying the buffer. Some edit commands can be followed by a motion.
h j k lLeft, down, up, right cursor movement.H J K LPage top, page down, page up, page bottom.^F ^BPage down (forward), page up (back).b e wWord left, word end, word right.^ $Start and end of line, ie.0|or999|.|Goto column (count) of physical line.%* Find matching brace, bracket, square bracket, or angle bracket./ERE/ERE/Find first occurrence ofEREpattern after the cursor./ERE/REPL/ERE/REPL/FindEREand replace. In theREPL, a$nwherenis a digit0..9is replaced by the Nth subexpression of the matched text;$0is the whole matched text.\xis an escape sequence, ie.\a\b\e\f\n\r\t\?orx./ERE/REPL/aFind and replace all occurences.m charSet a positional mark lettera..z.nFind next occurrence of ERE (and replace);uundoes only the most recent replacement.` charGoto position of mark`a .. `zor``(previous).' char* Goto start of line with mark'a .. 'zor''(previous), eg.`a^.GGoto line (count) number;1Gtop of file,Gbottom,123Gline 123.\Toggle highlighted text selection.c moveChange text selection or region given by motion.C* Change to end of line, ie.c$.d moveDelete text selection or region given by motion.D* Delete to end of line, ie.d$.O o* Open new line above or below the current line, ie.kA\norA\n.y moveYank (copy) text selection or region given by motion.Y* Yank the current line, ie.^yj.P pPaste last deleted or yanked text region before or after the cursor.i aInsert text mode before or after the cursor,ESCorCTRL+Cends insert. While inserting text, backspace will erase the previous character;CTRL+Vtreats the next character as a literal character.I A* Insert at start of line or append at end of line, ie.^ior$i.X xDelete character before or after cursor, ie.dhordl.U uRedo or undo one or more edits.~Invert character case.! move cmdFilter a text selection or region through shell command line, eg.!Gfmt -w68. Or read only the output of a shell command line, eg.!!ls -l.CTRL+XToggle hex digits in the range 0..10FFFF or a Unicode character left of the cursor.RRead a file into buffer after cursor.WWrite buffer to file.VShow build and version.CTRL+RRedraw the screen.CTRL+CQuit.QQuit.
-
SHELL: The user's shell of choice. -
TERM: The user's terminal type. If the environmental variableTERMis not set or insufficient then terminate with non-zero exit status. -
TERMINFO: The absolute file path of aterminfodatabase. Seeterminfo(5).
- 0 Success
- 1 Insufficient capabilities for
TERM. - 2 Read file error
ed(1), ex(1), vi(1)
-
Has UTF-8 support.
- Loads UTF-8 files as-is and internally remains UTF-8 (not converteed to
wchar_torchar32_t). - UTF-8 input will likely require an intl. keyboard or enabling US Intl. dead-key keyboard support. See also Unicode Input.
- Loads UTF-8 files as-is and internally remains UTF-8 (not converteed to
-
The display of long physical lines that are larger than the terminal screen is untested, so considered undefined.
-
Control characters, other than TAB and LF, are displayed as highlighted alphabetic characters.
-
uandUdo not behave as in historicalvi(1); they now provide multi undo and redo respectively. -
CRLF newlines (DOS, Windows) should be converted to LF newlines Consider converting newlines using SUS tools like
awk(1)orsed(1):$ sed -e's/^V^M$//' dos.txt > unix.txt $ sed -e's/$/^V^M/' unix.txt > dos.txt^Vis the defaultstty(1)insert literal prefix key. -
Cygwin builds may be bugged with respect to
wcwidth(), sincewchar_treflects UTF-16 to match Windows and there is no equivalentc32width()nor means to determine cell width of surrogate pairs, such as emoji.
-
Craig A. Finseth, "Craft Of Text Editing", 1991
Springer-Verlag, ISBN 0-387-97616-7, ISBN 3-3540-97616-7 -
Craig A. Finseth, "Craft Of Text Editing", 1999
http://www.finseth.com/craft/ -
Webb Miller, "A Software Tools Sampler", Prentice Hall, 1987
ISBN 0-13-822305-X, chapter 5 -
Single Unix Specification, Base Specification 2018, vi(1)
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html -
Single Unix Specification, Curses issue 7
https://pubs.opengroup.org/onlinepubs/9699909599/toc.pdf