-=[ ED - Unix Style Line Editor ]=-
The online editor is a clone of the Unix ed. This is a rehash
of the original ed docs. Only creators have access to the
online editor.
Ed has two modes, command mode and insert mode. Command mode
has the prompt ':', insert mode has no prompt.
<Insert Mode Commands>
Insert mode has only one command. By typing a single '.' at
the beginning of the line you exit insert mode, and enter
command mode. Otherwise, each line of text is added to the
document.
<Command Mode Command>
All commands in command mode will accept the following format,
<line1,line2>command - apply command from line1 to line2
<line1>command - apply command to line1
command - apply command to current line
For example:
:1,5d - delete from line 1 to line 5
:2d - delete line 2
:d - delete current line
If any numbers are out of range the command will fail.
<Commands>
Commands that use a line range:
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 10 lines.
a Start insert mode after specified line.
i Start insert mode before specified line.
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.
= print line number
h online ed help
<ed line reference tokens>
'.' - reference current line number.
A '.' is the "current line". The current line is
the last line referenced. If you want to print last line
+ 10 more:
.,.+10p
'$' - reference last line of file
A '$' is last line of file. Thus '1,$p' will always print
all of the file.
<ed commands can use Regular Expressions>
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.
<EXAMPLES>
-=- Pattern Searching -=- </>
Change the current line to the next occurance of the pattern.
Pattern searching can use regular expressions.
:/hello
search for the pattern 'hello' after the current line.
:/
repeat the last search pattern
-=- Substitute Command -=- <s>
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.
:s/ab.d/ABCD/
Substitute any string 'abXd' against 'ABCD' where X can be
any character. (see regular expressions)
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.
-=- Read a file into current document -=- <r>
You must have valid read access to read the file.
:r /room/church.c
Read the file /room/church.c into the current document at
the current line.
:r church.c
Read the file church.c from your default directory.
-=- Write document to an alternative file -=- <w>
You must have valid write access to write the file.
:w church2.c
Write the document to church2.c in you default directory.
:w /room/church2.c
Write the document to /room/church2.c
-=- Deleting lines -=- <d>
This will delete line(s) from the document.
:d
delete current line
:2d
delete line 2
:2,5d
delete from line 2 to 5
-=- Exiting ed -=- <x,q,Q>
There are 3 ways to exit the editor.
:x
exit and save all changes to the edited file
:q
exit only if no changes have been made
:Q
exit, DO NOT save changes