vi Editor
Intro

Intro

I was looking for a tiny editor which can be easily adapted and embedded into a (Forth) system. The vi EMACS war is over but others have won. However for me vi is better suited for restricted (embedded) systems. I have not used vi for a very long time, but to see a screen full with ~ at the beginning of the lines makes me feel like coming home. I never thought I would ever take the book Learning the vi Editor, by Linda Lamb, 5th edition 1990 off the bookshelf again for reading. I kept the book only for sentimental reasons.

My editor using history:

  • CP/M Turbo Pascal Editor (Wordstar) OKI if800, Z80 Assembler, Pascal, 1984
  • UNIX Rand Editor, Perkin Elmer, 1985
  • VMS EDT MicroVAX, Pascal, Oracle DB, 1987
  • vi (MKS Toolkit) IBM PC DOS cross-assembler for NEC's 75X 4-bit MCUs, Coherent OS, Linux, 1988
  • UNIX EMACS as system administrator for DEC Tru64 UNIX, SUN Solaris, and Linux servers, 1996
  • IDE (Eclipse, NetBeans, EWARM), 2010
  • Atom, VS Code; 2019

Features

This vi has its origin in BusyBox tiny vi. But there are some differences:
  • The program is resident. The text buffer and other buffers too. You can leave the program without saving, do some work on the command line and go back to vi and continue the edit task.
  • The text buffer is restricted to 40 KiB. Large files have to be split up.
  • 8-bit characters are allowed e.g. UTF8
  • Mecrisp Forth uses DOS/Windows style line endings carriage return and line feed ("\r\n"). Unix (and vi) uses just line feed ("\n"). Files are saved as Unix text files. https://vim.fandom.com/wiki/File_format
  • The command v evaluates a line. The command V evaluates a line and inserts the results into the text buffer.
  • :!<line> evaluates the line and put the result to the status line

Don't forget: you can't use any special keys (e.g. cursor movement keys) in the insert/replace mode. TABs are forbidden too, Mecrisp can't handle TABs.

Usage

vi [-R] [-h] [-c <COLUMNS>] [-r <ROWS>] [FILE..]
   -h show features
   -R Read-only mode. You can still edit the buffer, but will be prevented from overwriting a file.
   -e erase the text buffer
   -c <COLUMNS> screen columns, range 40..128 default 80
   -r <ROWS> screen rows, range 16..30 default 24

vi ( "line<EOL>" -- )  a (Forth) programmer's text editor

Full-fledged Editors

Emacs, Vim, Atom, Visual Studio Code.

Visual Studio Code with Forth extension:

VSCode-forth.png

-- Peter Schmid - 2020-08-29

Comments

Topic attachments
I Attachment History Action Size Date Who Comment
JPEGjpg Mecrisp-Cube-vi-header.jpg r1 manage 69.8 K 2020-09-23 - 18:20 PeterSchmid  
JPEGjpg Mecrisp-Cube-vi-header2.jpg r1 manage 75.0 K 2020-09-23 - 18:27 PeterSchmid  
PNGpng VSCode-forth.png r1 manage 17.2 K 2020-10-12 - 10:02 PeterSchmid  
C source code filec vi.c r1 manage 111.1 K 2020-10-02 - 21:18 PeterSchmid  
Edit | Attach | Watch | Print version | History: r15 < r14 < r13 < r12 < r11 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r15 - 2020-10-27 - PeterSchmid
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback