vi Screen Editor vi [-tn] [file] vi is a screen oriented text editor written in C that was originally part of the Manx Aztec C65 system and named VED. The original VED source has been heavily modified for an 8080 microprocessor running CP/M with a VT100 terminal or terminal emulator attached. It has been successfully compiled with the Manx Aztec C compiler version 1.06D. The vi editor contains a subset of the command keys used in the UNIX vi editor. If vi is invoked with a file name, that file will be loaded into the memory buffer, otherwise it will start with an empty edit screen. vi does all of its editing in memory and is limited to files around 30K in size on a CP/M system with 64K of memory. The "-t" option specifies the tab size to be used (default is 4): ved -t8 file.txt The maximum character length of a line in vi is 1000. If a line is longer than the width of the screen, it will wrap to the next line. If a line starts at the bottom of the screen, and is too wide to fit, the line will be displayed as a single '@' character. If a file is smaller than the screen, all lines beyond the end of the file will contain a single '~' character. The vi editor will start in the command mode. The command mode allows the cursor to be moved to any character in any line in the file, after which a command key may be entered to edit the characters in that line. Below is a list of keyboard commands that vi supports: Cursor and Screen Commands move cursor to the beginning of the next line. n move cursor to the beginning of the nth line. UP, k move cursor up one line. nUP, nk move cursor up n lines. DN, j move cursor down one line. nDN, nj move cursor down n lines. LT, h move cursor left one character. nLT, nh move cursor left n characters. RT, l move cursor right one character. nRT, nl move cursor right n characters. HM, 0 move cursor to beginning of the line. EN, $ move cursor to the end of the line. PGUP, CTRL-B move cursor up one page. PGDN, CTRL-F move cursor down one page. g goto last line in the file. ng goto line number n in the file. H move cursor to top of screen. M move cursor to middle of screen. L move cursor to bottom of screen. CTRL-L redraw the screen. Editing Commands i enter insert mode at cursor position. o open new line below cursor and enter insert mode. ESC exit insert mode and return to command mode. rc replace character under the cursor with character c. x delete character under the cursor. nx delete n characters under the cursor. dd delete line at the cursor. ndd delete n lines at the cursor. yy yank line at the cursor. nyy yank n lines at the cursor (1000 characters max). yd yank and delete line at the cursor. nyd yank and delete n lines at the cursor (1000 characters max) p put yanked lines below cursor. Deleting the last character on a line causes the next line to be appended to the current line. Entering insert mode using the 'i' or 'o' key will cause the status line to display "". To exit insert mode, press the ESCAPE key. There are three commands used for moving text around. These commands make use of a 1000 character yank buffer. The contents of this buffer is retained across files. Search Commands / search for string n repeat last search nn repeat last search n times File Commands ZZ Save file if changed and exit. :q Exit if file not changed. :q[!] Force exit if file changed. :w Write current file. :w filename Write to filename. :r filename Read file into buffer starting at cursor position. :e filename Edit new file if existing file not changed. :e! filename Edit new file discarding changes to existing file. :f Display file status on status line. Building vi from source Copy the vi.arc source file to the Manx Aztec C drive. Extract the vi.arc file replacing with the Aztec drive letter. unarc vi.arc : Run the make submit file. submit makevi When the make file completes the vi.com file will be created and can be copied to the drive of your choice. In the vi.h file there is one switch that controls the VT100 keyboard decoding. The VT100 keyboard decoder is in the assembly file getkey.asm. This assembly file has one equate that must be changed to the address of your BIOS conin routine. The reason I use an assembly file for the VT100 keyboard decoder is that the C library functions for console read and write aren't fast enough to keep up with a UART that doesn't use flow control. So I created a quick decoder in assembly that can. If your machine and BIOS support hardware flow control, then undefine the ANSIKEY variable in the vi.h file. If you do that, you can also edit the make file to remove getkey.asm and getkey.o. The vi source files were originally retrieved from the Manx Aztec C65 disk image and modified for the McCosh C compiler on a 6809 SWTPC machine with a Televideo 950 terminal. I don't know who originally modified them for the SWTPC. But I've taken those files and and further modified them for my 8080 CP/M machine connected to a VT100 terminal emulator like Putty or Tera Term. I've added several features and corrected several that were broken. Although I've tested the vi application agressively, any bugs found are likely caused by me. I've left the attribution to Manx at the top of the source files. This editor was originally called VED. Most probably to avoid complaints from AT&T. But since I've modified the VED editor to match a subset of the original vi keystrokes, there are already several unrelated editors called VED now, and we are probably well past anyone thinking that vi is some kind of trademark that needs to be vigorously protected, I decided to name the program "vi". But regardless, this program is not UNIX vi and is not based on UNIX vi source code. If somebody pitches a fit about this, given the world we live in today, I'll remove this editor from my website.