I love ED on CP/M. It's often derided but I think it's just misunderstood and with a little practise its true value can shine through. It's elegant, easy to learn and only has about 25 commands but these can be combined. Once you get used to it most editing tasks are pretty quick. If I'm editing text that is made up of separate lines, ideally not more than the width of the terminal, I find it excellent. It does have a line limit of 128 characters so for continuous prose I will switch to something like Wordstar, but for editing source code and config files on CP/M, it's my first choice.
ED came as standard with CP/M and is only 7k for CP/M 2.2 and 10k for CP/M Plus. One advantage of ED is that it will work both with teleprinters and video terminals without having to be configured for each device. It is also good at manipulating large files even when the system is short of memory.
Like many early editors, ED is a modal editor which you start in command mode and while in this mode you can view existing text, move between lines and points in the line. It allows you to do standard operations such as copy and paste, inserting text from other files, searching for and replacing text, etc. When we want to enter input mode, we can use the 'I' command. This is much like VI, except that you can only enter text in the non-command mode but not edit it. To exit data input mode and return to command mode you use ^Z (CTRL-Z). These commands can be combined together and one of the most powerful facilities that ED has is the 'M' Macro command to repeat sequences of commands.
Upon executing ED it creates a temporary output file and as you write out from ED it goes to this temporary file. When editing a file we append text from it into the memory buffer and save to the temporary output file as we go or at the end.
ED keeps track of a number of values such as where it is in the source file, the line number in the memory buffer and the character pointer (CP) on the line. These are altered as you move around the file and memory buffer.
I'm not going to give a fuller explanation of how to use ED here because the CP/M 2.2 Operating Manual has a good section on the CP/M Editor. I do, however, want to show it being used properly in the video below. Further down in this article I have highlighted some useful command sequences.
An Example Macro
ED has a macro facility which allows you to repeat a sequence of commands as many times as you like. This makes it a good example of the power of ED and the following is a typical macro which searches through the memory buffer and displays any occurrences of the text 'CPM', pauses in case you want to stop the macro and then replaces it with 'CP/M'.
The 'M' command will run the sequences of commands that follows it until an error is raised, such as end of file. If we wanted to we could prepend 'M' with a number to indicate the number of times we want it to run. I'll break down each command in the sequence below:
|Run the following command sequence until an error|
|Find 'CPM' and leave Character Pointer (CP) after it|
|Display the line up to CP|
|Display the rest of the line from CP to end|
|Move CP back 3 characters|
|Substitute 'CPM' for 'CP/M'|
^Z in the above is CTRL-Z and indicates the end of an argument for a command.
The above macro could also be written:
In which case:
|Delete the 3 previous characters|
|Insert the text 'CP/M'|
Common Command Sequences
Below are some useful command command sequences which may be overlooked when reading the manual for ED.
|#A||Load whole file into buffer|
|0A||Load enough of the file to fill half the buffer. This is great for large files|
|#W0A||Save entire buffer and load more of the source file, enough to fill half of the buffer. Useful to move through large files.|
|0W||Write half of the buffer to the new file. Useful to make room if the buffer is full.|
|-B||Move to end of the last line in the buffer|
|0L||Move CP to beginning of line|
|L-2C||Move to end of line before the <cr><lf> sequence|
|0P||Display page from CP without moving CP|
|0LT||Move CP to beginning of line and display line|
|0T||Type line up to but not including CP|
|0TT||Type whole line without moving CP|
|0T<cr>T||Type whole line without moving CP. Display up to CP on first list and from CP on next line. This is useful to see where CP is on line.|
|B#T||Display the whole buffer|
|KI||Replace a line|
|0K||Delete up to CP on current line|
|S^L^Z||Join current line with next|
|I^L^Z||To split a line at CP|
|0V||Print free/total memory buffer stats|
|0X||Empties the temporary default exchange file: X$$$$$$$.LIB, used by the X command|
In the table above the following holds true:
- Represents the highest value for n
- CTRL-L - Stands for carriage return sequence <cr><lf>
- CTRL-Z - Indicates the end of a command's argument
- Carriage Return - Actually pressing the Return key
Do You Like ED Too?
I know that I'm in the minority, but I'm sure there must be other people who also like ED. I'd love to hear if I'm not alone in this. You can leave comments via the links below or via the YouTube video above.
The videos below show ED being used properly and some of the things that make it great, including searching and replacing text, copying and pasting, macros and handling files bigger than the available memory. There are two videos below, the second is a concise edit of the first so there is no need to watch both.
I Love ED on CP/M
This is a fairly detailed demonstration of most of ED's commands.
A Very Quick Tour of ED
This is a concise edit of the first video down to about 5 minutes long. It showcases most of the commands but doesn't give as detailed an explanation.