I Love ED on CP/M

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:

MRun the following command sequence until an error
FCPM^ZFind 'CPM' and leave Character Pointer (CP) after it
0TDisplay the line up to CP
TDisplay the rest of the line from CP to end
-3CMove CP back 3 characters
SCPM^ZCP/M^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:

-3DDelete the 3 previous characters
ICPM^ZInsert the text 'CP/M'

Common Command Sequences

Below are some useful command command sequences which may be overlooked when reading the manual for ED.

#ALoad whole file into buffer
0ALoad enough of the file to fill half the buffer. This is great for large files
#W0ASave entire buffer and load more of the source file, enough to fill half of the buffer. Useful to move through large files.
0WWrite half of the buffer to the new file. Useful to make room if the buffer is full.
-BMove to end of the last line in the buffer
0LMove CP to beginning of line
L-2CMove to end of line before the <cr><lf> sequence
0PDisplay page from CP without moving CP
0LTMove CP to beginning of line and display line
0TType line up to but not including CP
0TTType whole line without moving CP
0T<cr>TType 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#TDisplay the whole buffer
KIReplace a line
0KDelete up to CP on current line
S^L^ZJoin current line with next
I^L^ZTo split a line at CP
0VPrint free/total memory buffer stats
0XEmpties 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.

Creative Commons License
I Love ED on CP/M by Lawrence Woodman is licensed under a Creative Commons Attribution 4.0 International License.

Share This Post


Related Articles

Installing ZDE 1.6, a programmers editor for CP/M

To do any serious programming under CP/M, the first thing you need is a good programmers editor. There aren't many in the archives, but I have tried most of them and found ZDE to be the best. It is s...   Read More

Modula-2 Compilers on CP/M

Modula-2 is a great language in general and is a good choice for programming on CP/M. There are three good compilers available for CP/M which all require a Z80 processor and we'll compare each in turn...   Read More

XCCP: A Shell Extension for CP/M

XCCP describes itself as an Extended Console Command Processor for CP/M. It supports the 8080 and v1.0 was released by Anton R. Fleig in 1984. Like EPEX, XCCP doesn't require installing so we can begi...   Read More

EPEX: An Environment Extension for CP/M

Epex is an evironment extension for CP/M. It stands for Environmental Processing EXecutive, and v1.1 was released by James H. Whorton in 1986. It can make using CP/M much more comfortable at the cost...   Read More

File Comparison Utilities on CP/M

There are many utilities available for CP/M to compare the differences between files and to distribute those differences. All the utilities in this article can be found on the Walnut Creek CD. Binary ...   Read More