The ed Text Editor

A few hints on the program (Ver 1.0)

Running ed
Ed has two modes: input and command. Input is used to place text into the buffer for later writing to a file. Command mode tells ed how to handle files and what to do with data already in the buffer.
Input Mode

Command Mode
The generic command structure is: [address[,addresss]] command [parameters or destination address]

One concept to grasp when using ed is that of the current line or current address. It's the default address in the buffer on which commands work if no address is supplied. It changes constantly. The current address is initially set to the last line of a file read into the buffer. And generally, it's then set to the address of the last line (or the last of a range of lines) that's been changed by a command. Typing ".=" will give you the line number of the current address. You can also type "n" by itself to see both the number AND the text of the current address.

The address of 0 is always the first line of the buffer. The command 0a appends *before* first line, making whatever text is input the new first line.

(n,n) sets a range of numbers upon which to act. (n;n) sets the range from the current line to line n. In both cases, if only the first n is given, the second address is set equal to n. If only the second n is given, the range (1,n) is assumed; for (;n), the range of (current line, n) is assumed.

Regular expressions can also be used to set ranges. For example, "8,/foo/p" will print every line between line 8 and the first line containing "foo." Regular expressions can be used for *both* ends of a range. "/begin/,/end/d" will delete all lines beginning with the first match of "begin" and stop at the first match of "end."

Line address symbols:

Text-related commands:

File- and program-handling commands:

Regular Expressions
Regular expressions are the heart of the ed editor. Ed, after all, was the basis for sed and grep; and to this day the diff command is still capable of outputting an ed script that will change one file into another--a holdover from pre-sed days.

Regular expressions are a study unto themselves. Whole books have been written about them. If you don't know what a regex is or how they work, a good place to start is the man page for the grep command or 'info ed.'

Further information:

~~~~~~~~~~~~~~~~~~~~~~~~~
~Thumos thumos [at] tilde [dot] club May 2023