Command Reference — modred (CP/M ED minimal Python implementation)
This document summarizes the commands implemented by the modred project (modred.py). The goal is to follow the CP/M ED manual (Chapter 2) behavior as closely as practical for a small Python program.
Each command may accept numeric prefixes, signed prefixes +n/-n, or # meaning 65535.
Summary (core commands)
nA— Append nextnunprocessed source lines to the memory buffer (use#Ato append all).OAappends until buffer at least half full.nW— Write the firstnlines of the memory buffer to the temporary filex.$$$.OWwrites until buffer is at most half full.#Wwrites the entire buffer.I/i— Insert mode. Enter lines from the console until Ctrl-Z (ASCII SUB) or a line containing^Z.I(uppercase) translates inserted text to uppercase;ipreserves case.T/nT— Type lines from the buffer (display). WithVenabled,Tprints absolute line numbers.E— End edit: write remaining buffer and unprocessed source to the temporary file, rename original to.BAK, and renamex.$$$→ original file name.Q— Quit without saving changes.O— Return to original file (remove temporary changes, delete temp file, resetSP).H— Head: performE(save) and reopen the file for editing (starts a new edit session on the resulting file).D/+-nD— Delete characters; signed form deletes forward or backward.K/+-nK— Kill lines (remove lines) forward/backward relative to current line (preserves text before/after CP as specified by manual).C/+-nC— Move the character pointer byncharacters (counts CRLF as two chars between lines).L/+-nL— Movenlines up/down.L0moves to the beginning of the current line.B/-B— Move to beginning (B) or bottom (-B) of buffer.V,-V,0V— Turn line numbering on (V) or off (-V);0Vprintsfree/totalbuffer bytes.U,-U— Toggle uppercase translation of appended input.
Search & replace
nF s— Find the nth occurrence ofsstarting at the current CP. Strings may include^Lto represent a<CR><LF>pair.nN s— Find with autoscan: ifsis not found in the current buffer, the implementation writes the buffer to temp and appends more source (likeA/W) until the search succeeds or source exhausted.nS s1^Zs2— Substitute occurrences ofs1withs2, at mostntimes (0 means until end).Senforces a 100-character limit on search strings and will printBREAK > AT 0if exceeded.nJ s1^Zs2^Zs3— Juxtaposition: finds1, inserts2right after it, then delete up to (but not including)s3.
Libraries & block move
nX— Transfer the nextnlines from the buffer (starting at current line) into a temporary transferred library (kept in memory and persisted to an on-disk filebase.LIB.XTMP) — does not remove from buffer.0X— Clear the transferred lines (deletes the temporary lib file if present).R— Read transferred lines fromXback into the buffer after the CP.Rname— Readname.LIBfrom disk and insert it after CP.
Macros
nM cs— Execute command stringcsntimes; ifnis 0 or 1, execute until an error condition. NestedMcalls are disallowed and will reportBREAK ? AT 0.
Error messages
BREAK ? AT C— general unrecognized command or macro problem.BREAK > AT 0— memory/line length exceeded for some operations (search strings too long).BREAK O AT 0— library open error (cannot open.LIB).BDOS ERR on d: BAD SECTOR— disk write error (simulated during temp-file writes).
Limits & behaviors
- Line lengths and total buffer sizes are approximate and limited by
DEFAULT_BUFFER_CAPACITY(by default ~5000 characters) and manual-enforced safeguards. - Strings passed to
F,S,N, andJare limited to 100 characters in the current implementation.
Notes & examples
- When inserting interactively on a TTY, pressing Ctrl-Z (ASCII SUB) will end insert mode without suspending the process.
- For
Scommands use^Zseparators when providing boths1ands2, e.g.,SOLD^ZNEW^ZreplacesOLDwithNEW.
For usage examples, see docs/EXAMPLES.md.