This is just a quick put-together from the old docs about ed. If anyone
would feel like fixing better docs on ed I would be most grateful. Since
I avoid using ed myself, I'm not too familiar with it :( But when one
has to code something in the game, ed is the only editor available.
(I try to edit my files at home, and ftp them over, if you are unsure
how ftp works, as an elder wizard.)

When in ed 'h' will give you the list of possible commands. If this
documentation describes a command different from the 'h', then it's
probably the 'h' that is correct, and please contact me then so I can
uddate this file.

/Nick


Introduction (or something)
===========================

When in 'ed', the prompt is ':'.

Ed has two modes, command mode and insert mode. The insert mode has
no prompt. You exit the insert mode by typing a single '.' on a line.

All commands have the following syntax:

X,Ycmd

or

Xcmd

For example:

1,10p
Will print line 1 to 10.
1,5d
Will delete line 1 to 5.
8p
Will print line 8.

A '.' is the "current line". The current line is the last line
referenced. If you want to print last line + 10 more:
.,.+10p


Commands that use a line range:
===============================

If no line is given, then curent line is printed.

p       Print line.
d       Delete line.
l       Print line with control characters.
r file  Read in a file after the line specified.
s       Substitute patterns. See special documentation.
z       Print 20 lines.
a       Start insert mode after specified line. Exit with '.'<return>.
i       Start insert mode before specified line. Exit with '.'<return>.

Commands used without line specification:

q       Quit. Won't work if file is changed.
Q       Quit and discard all changes if not saved.
w       Write the file out.
w file  Write the file out with name 'file'.
e file  Edit a file.
!cmd    Give a game command. For example "!say Wait, I am busy".

As line numbers '.' is current line, and '$' is last line of file.
Thus '1,$p' will always print all of the file.



Substitutions are very advanced.
================================

First a simple example:

s/apa/bepa/
This will substitue the 'apa' in current line to 'bepa'.
If an 'p' is appended, you will also immediately see the result.

1,$s/apa/bepa/
Same, but all lines in file. Only first occurence on every line.

Any character can used instead of '/':
s!apa!bepa!g
The 'g' specifies that all occurences of apa on this line are changed to bepa.

The pattern that are supposed to be replaced, can be a regular expression.


Searching is done with:
=======================

/hello/
Find first line in of after current line.
Just // will repeat the search.


Special characters
==================

There are special characters that can be used in the pattern:
.       Match any character.
x*      Match any numbers of x (0 or more).
[abc]   Match 'a', 'b' or 'c'.
[0-9]   Match any digit 0 - 9.
[a-z]   Match any lowercase letter.
\x      Match 'x' where 'x' can be any character except '(' and ')'.

Example:
s/ab.d/ABCD/
Substitute any string 'abXd' against 'ABCD' where X can be any character.


How to copy from a standard file.
=================================

Enter 'ed xxx'. Then do 'r /d/Genesis/start/elf/v/stables.c'. Now you have
something in the buffer. Change it into what you want it to be. Then 
'w /d/Krynn/nick/hall.c' or 'w hall.c', exit with 'q'.


Why do I sometimes get 'No error' when I type just 'ed' ?
=========================================================

One nice feature in ed is that if you have edited a file under your home
directory, try to clone it or load it and an error occurs, you can type
'ed' without argument, and ed will be set up for the file where the error
happened plus it will write the first error found in that file.


