.bp 1
.op
.cs 5
.mt 5
.mb 6
.pl 66
.ll 65
.po 10
.hm 2
.fm 2
.he
.ft                                2-%
.pc 1
.tc 2  The CP/M Editor
.ce 2
.sh
Section 2
.sp
.sh
The CP/M Editor
.sp 3
.tc    2.1  Introduction to ED
.he CP/M Operating System Manual              2.1  Introduction to ED
.sh
2.1  Introduction to Ed
.qs
.pp 5
Ed is the context editor for CP/M, and is used to create and alter CP/M source
files.  To start ED, type a command of the following form:
.sp
.nf
.ti 8
ED filename
or
.ti 8
ED filename.typ
.fi
.sp
Generally, ED reads segments of the source file given by filename or
filename.typ into the central memory, where you edit the file
and it is subsequently written back to disk after alterations.  If the
source file does not exist before editing, it is created by ED and
initialized to empty.  The overall operation of Ed is shown in
Figure 2-1.
.sp 2
.tc         2.1.1  ED Operation
.sh
2.1.1  ED Operation
.qs
.pp
Ed operates upon the source file, shown in Figure 2-1 by x.y, and passes
all text through a memory buffer where the text can be viewed or altered.
The number of lines that can be maintained in the memory buffer varies with
the line length, but has a total capacity of about 5000 characters in a 20K
CP/M system.
.pp
Edited text material is written into a temporary
work file under your command.  Upon termination of the edit, the
memory buffer is written to the temporary file, followed by any remaining
(unread) text in the source file.  The name of the original file is changed
from x.y to x.BAK so that the most recent edited source file can
be reclaimed if necessary.  See the CP/M commands ERASE and RENAME.  The
temporary file is then changed from x.$$$ to x.y, which becomes the resulting
edited file.
.pp
The memory buffer is logically between the source file and working file, as
shown in Figure 2-2.
.bp
.sp 27
.ce
.sh
Figure 2-1.  Overall ED Operation
.sp 3
.nf
       Source File         Memory Buffer       Temporary File

    1   First Line      1   First Line       1   First Line
    2    Appended       2    Buffered        2   Processed
    3     Lines         3      Text          3      Text



   SP                  MP                   TP



       Unprocessed  Next       Free     Next      Free File
         Source     Append    Memory    Write       Space
         Lines                Space



                        SP = Source Pointer
                        MP = Memory Pointer
                        TP = Temporary Pointer
.sp 2
.fi
.ce
.sh
Figure 2-2.  Memory Buffer Organization
.bp
.tc         2.1.2  Text Transfer Functions
.sh
2.1.2  Text Transfer Functions
.qs
.pp
Given that n is an integer value in the range 0 through 65535, several
single-letter ED commands transfer lines of text from the source file through
the memory buffer to the temporary (and eventually final) file.  Single letter
commands are shown in upper-case, but can be typed in either upper- or
lower-case.
.sp 2
.ce
.sh
Table 2-1.  ED Text Transfer Commands
.sp
   Command                          Result
.sp
.ll 60
.in 15
.ti -10
nA        Appends the next n unprocessed source lines from the source file at
SP to the end of the memory buffer at MP.  Increment SP and MP by n.  If
upper-case translation is set (see the U command) and the A command is typed
in upper-case, all input lines will automatically be translated to upper-case.
.sp
.ti -10
nW        Writes the first n lines of the memory buffer to the temporary
file free space.  Shift the remaining lines n+1 through MP to the top of the
memory buffer.  Increment TP by n.
.sp
.ti -10
E         Ends the edit.  Copy all buffered text to temporary file and copy
all unprocessed source lines to temporary file.  Rename files.
.sp
.ti -10
H         Moves to head of new file by performing automatic E command.  The
temporary file becomes the new source file, the memory buffer is emptied, and
a new temporary file is created.  The effect is equivalent to issuing an E
command, followed by a reinvocation of ED, using x.y as the file to edit.
.sp
.ti -10
O         Returns to original file.  The memory buffer is emptied, the
temporary file is deleted, and the SP is returned to position 1 of the
source file.  The effects of the previous editing commands are thus nullified.
.sp
.ti -10
Q         Quits edit with no file alterations, returns to CP/M.
.in 0
.ll 65
.sp
.pp
There are a number of special cases to consider.  If the integer n is omitted
in any ED command where an integer is allowed, then 1 is assumed.  Thus, the
commands A and W append one line and write one line, respectively.  In
addition, if a pound sign # is given in the place of n, then the integer
65535 is assumed (the largest value for n that is allowed).  Because most
source files can be contained entirely in the memory buffer,
the command #A is often issued at the beginning of the edit to read the
entire source file to memory.  Similarly, the command #W writes the entire
buffer to the temporary file.
.pp
Two special forms of the A and W commands
are provided as a convenience.  The command 0A fills the current memory
buffer at least half full, while 0W writes lines until the buffer is at least
half empty.  An error is issued if the memory buffer size is exceeded.
You can then enter any command, such as W, that does not increase
memory requirements.  The remainder of any partial line read during the
overflow will be brought into memory on the next successful append.
.sp 2
.tc         2.1.3  Memory Buffer Organization
.sh
2.1.3  Memory Buffer Organization
.qs
.pp
The memory buffer can be considered a sequence of source lines brought
in with the A command from a source file.  The memory buffer has an imaginary
character pointer (CP) that moves throughout the memory buffer
under command of the operator.
.pp
The memory buffer appears logically as shown
in Figure 2-3, where the dashes represent characters of the source line of
indefinite length, terminated by carriage return (<cr>) and line-feed (<lf>)
characters, and CP represents the imaginary character pointer.
Note that the CP is always located ahead of the first character of the
first line, behind the last character of the last line, or between two
characters.  The current line CL is the source line that contains the CP.
.sp 3
.nf
                          Memory Buffer


      first line        -----------------------<cr><lf>


                        -----------------------<cr><lf>


      current line CL   ---------------------------<cr><lf>


                                    CP

      last line         -----------------------<cr><lf>
.sp 2
.sh
        Figure 2-3.  Logical Organization of Memory Buffer
.qs
.fi
.sp 5
.tc         2.1.4  Line Numbers and ED Start-up
.sh
2.1.4  Line Numbers and ED Start-up
.qs
.pp
ED produces absolute line number prefixes that are used to reference a
line or range of lines.  The absolute line number is displayed at the
beginning of each line when ED is in insert mode (see the I command in
Section 2.1.5). Each line number takes the form
.sp
.ti 8
nnnnn:
.sp
where nnnnn is an absolute line number in the range of 1 to 65535.  If the
memory buffer is empty or if the current line is at the end of the memory
buffer, nnnnn appears as 5 blanks.
.pp
You can reference an absolute line number by preceding any command by
a number followed by a colon, in the same format as the line number display.
In this case, the ED program moves the current line reference to the absolute
line number, if the line exists in the current memory buffer.  The line
denoted by the absolute line number must be in the memory buffer (see the
A command).  Thus, the command
.sp
.ti 8
345:T
.sp
is interpreted as move to absolute 345, and type the line.   Absolute line
numbers are produced only during the editing process and are not recorded
with the file.  In particular, the line numbers will change following a
deleted or expanded section of text.
.pp
You can also reference an absolute line number as a backward or forward
distance from the current line by preceding the absolute number by a colon.
Thus, the command
.sp
.ti 8
:400T
.sp
is interpreted as type from the current line number through the line whose
absolute number is 400.  Combining the two line reference forms, the
command
.sp
.ti 8
345::400T
.sp
is interpreted as move to absolute line 345, then type through
absolute line 400.  Absolute line references of this sort can precede any
of the standard ED commands.
.pp
Line numbering is controlled by the V (Verify Line Numbers) command.  Line
numbering can be turned off by typing the -V command.
.bp
If the file to edit does not exist, ED displays the following message:
.sp
.ti 8
NEW FILE
.sp
To move text into the memory buffer, you must enter an i command before typing
input lines and terminate each line with a carriage return.  A single
CTRL-Z character returns ED to command mode.
.sp 2
.tc         2.1.5  Memory Buffer Operation
.sh
2.1.5  Memory Buffer Operation
.qs
.pp
When ED begins, the memory buffer is empty.  You can either append
lines from the source file with the A command, or enter the lines directly
from the console with the insert command.  The insert command takes the
following form:
.sp
.ti 8
I
.sp
ED then accepts any number of input lines.  You must terminate each line with
a <cr> (the <lf> is supplied automatically).  A single CTRL-Z, denoted
by a caret (^)Z, returns ED to command mode.  The CP is positioned after the
last character entered.  The following sequence:
.sp
.in 8
.nf
I<cr>
NOW IS THE<cr>
TIME FOR<cr>
ALL GOOD MEN<cr>
^Z
.fi
.in 0
.sp
leaves the memory buffer as
.sp
.in 8
.nf
NOW IS THE<cr><lf>
TIME FOR<cr><lf>
ALL GOOD MEN<cr><lf>
.fi
.in 0
.pp
Generally, ED accepts command letters in upper- or lower-case.  If the
command is upper-case, all input values associated with the command are
translated to upper-case.  If the I command is typed, all
input lines are automatically translated internally to upper-case.  The
lower-case form of the i command is most often used to allow both upper- and
lower-case letters to be entered.
.pp
Various commands can be issued that control the CP or display source text
in the vicinity of the CP.  The commands shown below with a preceding n
indicate that an optional unsigned value can be specified.  When preceded
by +\b_, the command can be unsigned, or have an optional preceding plus or
minus sign.  As before, the pound sign # is replaced by 65535.  If an
integer n is optional, but not supplied, then n=1 is assumed.  Finally, if a
plus sign is optional, but none is specified, then + is assumed.
.bp
.ce
.sh
Table 2-2.  Editing Commands
.sp
   Command                       Action
.sp
.ll 60
.in 15
.ti -10
+\b_B        Move CP to beginning of memory buffer if + and to bottom if -.
.sp
.ti -10
+\b_nC       Move CP by +\b_n characters (moving ahead if +), counting the
<cr><lf> as two characters.
.sp
.ti -10
+\b_nD       Delete n characters ahead of CP if plus and behind CP if minus.
.sp
.ti -10
+\b_nK       Kill (remove) +\b_n lines of source text using CP as the
current reference.  If CP is not at the beginning of the current line when K
is issued, the characters before CP remain if + is specified, while the
characters after CP remain if - is given in the command.
.sp
.ti -10
+\b_nL       If n = 0, move CP to the beginning of the current 
line, if it is
not already there.  If n =\b/ 0, first move the CP to the beginning of the
current line and then move it to the beginning of the line that is n lines
down (if +) or up (if -).  The CP will stop at the top or bottom of the
memory buffer if too large a value of n is specified.
.sp
.ti -10
+\b_nT       If n = 0, type the contents of the current line up to CP.  If
n = 1, type the contents of the current line from CP to the end of the line.
If n>1, type the current line along with n - 1 lines that follow, if + is
specified.  Similarly, if n>1 and - is given, type the previous n lines up to
the CP.  Any key can be depressed to abort long type-outs.
.sp
.ti -10
+\b_n        Equivalent to +\b_nLT, which moves up or down and types a
single line.
.in 0
.ll 65
.sp 3
.tc         2.1.6  Command Strings
.sh
2.1.6  Command Strings
.qs
.pp
Any number of commands can be typed contiguously (up to the capacity of
the console buffer) and are executed only after you press the <cr>.  Table 2-3
summarizes the CP/M console line-editing commands used to control the input
command line.
.bp
.ce
.sh
Table 2-3.  Line-editing Controls
.sp
     Command                      Result
.sp
.ll 60
.in 16
.ti -11
CTRL-C     Reboots the CP/M system when typed at the start of a line.
.sp
.ti -11
CTRL-E     Physical end of line:  carriage is returned, but line is not sent
until the carriage return key is depressed.
.sp
.ti -11
CTRL-H     Backspaces one character position.
.sp
.ti -11
CTRL-J     Terminates current input (line-feed).
.sp
.ti -11
CTRL-M     Terminates current input (carriage return).
.sp
.ti -11
CTRL-R     Retypes current command line:  types a clean line character
deletion with rubouts.
.sp
.ti -11
CTRL-U     Deletes the entire line typed at the console.
.sp
.ti -11
CTRL-X     Same as CTRL-U.
.sp
.ti -11
CTRL-Z     Ends input from the console (used in PIP and ED).
.sp
.ti -11
rub/del    Deletes and echos the last character typed at the
console.
.in 0
.ll 65
.sp
.pp
Suppose the memory buffer contains the characters shown in the 
previous section, with the CP following the last character of the 
buffer.  In the following example, the command strings on the left produce
the results shown to the right.  Use lower-case command letters to avoid
automatic translation of strings to upper-case.
.sp 2
  Command String                      Effect
.sp
.fi
.in 20
.ll 60
.ti -15
B2T<cr>        Move to beginning of the buffer and type two lines:
.nf
.sp
NOW IS THE
TIME FOR
.fi
The result in the memory buffer is
.sp
.nf
NOW IS THE<cr><lf>
TIME FOR<cr><lf>
ALL GOOD MEN<cr><lf>
.fi
.in 0
.bp
  Command String                      Effect
.in 20
.sp
.ti -15
5C0T<cr>       Move CP five characters and type the beginning of the line NOW
I.  The result in the memory buffer is
.sp
NOW I  S THE<cr><lf>
.sp 2
.ti -15
2L-T<cr>       Move two lines down and type the previous line TIME FOR.
The result in the memory buffer is
.sp
.nf
NOW IS THE<cr><lf>
TIME FOR<cr><lf>
ALL GOOD MEN<cr><lf>
.fi
.sp 2
.ti -15
-L#K<cr>       Move up one line, delete 65535 lines that follow.  The result
in the memory buffer is
.sp
NOW IS THE<cr><lf>
.sp 2
.ti -15
I<cr>          Insert two  lines of text with  automatic
.ti -15
TIME TO<cr>    translation to upper-case.  The result in
.ti -15
INSERT<cr>     the memory buffer is
.ti -15
^Z
.sp
.nf
NOW IS THE<cr><lf>
TIME TO<cr><lf>
INSERT<cr><lf>
.fi
.sp 2
.ti -15
-2L#T<cr>      Move up two lines and type 65535 lines ahead of CP NOW IS THE.
The result in the memory buffer is
.sp
.nf
NOW IS THE<cr><lf>
TIME TO<cr><lf>
INSERT<cr><lf>
.fi
.sp 2
.ti -15
<cr>           Move down one line and type one line INSERT.  The result in
the memory buffer is
.sp
.nf
NOW IS THE<cr><lf>
TIME TO<cr><lf>
INSERT<cr><lf>
.fi
.in 0
.ll 65
.bp
.tc         2.1.7  Text Search and Alteration
.sh
2.1.7  Text Search and Alteration
.qs
.pp
ED has a command that locates strings within the memory
buffer.  The command takes the form
.sp
.nf
.ti 8
nF s <cr>
or
.ti 8
nF s ^Z
.fi
.sp
where s represents the string to match, followed by either a <cr>
or CTRL-Z, denoted by ^Z.  ED starts at the current position
of CP and attempts to match the string.  The match is attempted n
times and, if successful, the CP is moved directly after the
string.  If the n matches are not successful, the CP is not moved
from its initial position.  Search strings can include CTRL-L,
which is replaced by the pair of symbols <cr><lf>.
.pp
The following commands illustrate the use of the F command:
.sp 2
  Command String                      Effect
.in 20
.sp
.ll 60
.ti -15
B#T<cr>        Move to the beginning and type the entire buffer.  The result
in the memory buffer is
.sp
.nf
NOW IS THE <cr><lf>
TIME FOR<cr><lf>
ALL GOOD MEN<cr><lf>
.fi
.sp 2
.ti -15
FS T<cr>       Find the end of the string S T.  The result in the memory
buffer is
.nf
.sp
NOW IS T  HE<cr><lf>
.fi
.sp 2
.ti -15
FIs^Z0TT       Find the next I and type to the CP; then type the remainder
of the current line ME FOR.  The result in the memory buffer is
.nf
.sp
NOW IS THE<cr><lf>
TI  ME FOR<cr><lf>

ALL GOOD MEN<cr><lf>
.fi
.in 0
.ll 65
.sp
.pp
An abbreviated form of the insert command is also allowed, which
is often used in conjunction with the F command to make simple
textual changes.  The form is
.sp
.ti 8
.nf
| s ^Z
or
.ti 8
| s<cr>
.fi
.sp
where s is the string to insert.  If the insertion string is
terminated by a CTRL-Z, the string is inserted directly following
the CP, and the CP is positioned directly after the string.  The
action is the same if the command is followed by a <cr> except
that a <cr><lf> is automatically inserted into the text following
the string.  The following command sequences are examples
of the F and I commands:
.sp 2
  Command String                      Effect
.in 20
.ll 60
.sp
.ti -15
BITHIS IS ^Z<cr>
.sp
Insert THIS IS at the beginning of the text.  The result in the
memory buffer is
.sp
THIS IS  NOW THE<cr><lf>
.nf

TIME FOR<cr><lf>
ALL GOOD MEN<cr><lf>
.sp 2
.fi
.ti -15
FTIME^Z-4DIPLACE^Z<cr>
.sp
Find TIME and delete it; then insert PLACE.  The result in the memory
buffer is
.nf
.sp
THIS IS NOW THE<cr><lf>
PLACE    FOR<cr><lf>

ALL GOOD MEN<cr><lf>
.sp 2
.ti -15
3FO^Z-3D5D1
.fi
.ti -15
CHANGES^Z<cr>  Find  third  occurrence of O (that is, the
second O in GOOD),
delete previous 3 characters and the subsequent 5 characters; then insert
CHANGES.  The result in the memory buffer is
.nf
.sp
THIS IS NOW THE<cr><lf>
PLACE FOR<cr><lf>
ALL CHANGES   <cr><lf>
.fi
.sp 2
.ti -15
-8CISOURCE<cr>
.sp
Move back 8 characters and insert the line SOURCE<cr><lf>.  The result in the
memory buffer is
.nf
.sp
THIS IS NOW THE<cr><lf>
PLACE FOR<cr><lf>
ALL SOURCE<cr><lf>
   CHANGES<cr><lf>
.fi
.ll 65
.in 0
.sp
.pp
ED also provides a single command that combines the F and I
commands to perform simple string substitutions.  The command
takes the following form:
.sp
.nf
.ti 8
nS  s\d1\u^Zs\d2\u <cr>
or
.ti 8
nS s\d1\u^Zs\d2\u  ^Z
.fi
.sp
and has exactly the same effect as applying the following command
string a total of n times:
.sp
.nf
.ti 8
F s\d1\u^Z-kDIs\d2 <cr>
or
.ti 8
F s\d1\u^Z-kDIs\d2\u ^Z
.fi
.sp
where k is the length of the string.  ED searches the
memory buffer starting at the current position of CP and
successively substitutes the second string for the first string
until the end of buffer, or until the substitution has been
performed n times.
.pp
As a convenience, a command similar to F is provided by ED that
automatically appends and writes lines as the search proceeds.
The form is
.sp
.nf
.ti 8
n N s <cr>
or
.ti 8
n N s ^Z
.fi
.sp
which searches the entire source file for the nth occurrence of 
the strings (you should recall that F fails if the string 
cannot be found in the current buffer).  The operation of the N 
command is precisely the same as F except in the case that the 
string cannot be found within the current memory buffer.  In this 
case, the entire memory content is written (that is, an automatic #W 
is issued).  Input lines are then read until the buffer is at 
least half full, or the entire source file is exhausted.  The 
search continues in this manner until the string has been found n 
times, or until the source file has been completely transferred to 
the temporary file.
.pp
A final line editing function, called the juxtaposition command, 
takes the form
.sp
.nf
.ti 8
n J s\d1\u^Zs\d2\u^Zs\d3\u <cr>
or
.ti 8
n J s\d1\u^Zs\d2\u^Zs\d3\u ^Z
.fi
.sp
with the following action applied n times to the memory buffer: search from
the current CP for the next occurrence of the string s1.  If found,
insert the string s2, and move CP to follow s2.  Then delete all
characters following CP up to, but not including, the string s\d3\u, leaving
CP directly after s\d2\u.  If s\d3\u cannot be found, then no deletion is
made.  If the current line is
.sp 4
.ti 8
.nf
NOW IS THE TIME<cr><lf>
.sp
the command
.sp
.ti 8
JW ^ZWHAT^Z^1<cr>
.sp
results in
.sp
.ti 8
NOW WHAT <cr lf>
.fi
.sp
You should recall that ^1 (CTRL-L) represents the pair 
<cr><lf> in search and substitute strings.
.pp
The number of characters ED allows in the F, S, N, and J 
commands is limited to 100 symbols.
.sp 2
.tc         2.1.8  Source Libraries
.sh
2.1.8  Source Libraries
.qs
.pp
ED also allows the inclusion of source libraries during the 
editing process with the R command.  The form of this command is
.sp
.nf
.ti 8
R filename ^Z
or
.ti 8
R filename <cr>
.fi
.sp
where filename is the primary filename of a source file on the 
disk with an assumed filetype of LIB.  ED reads the specified 
file, and places the characters into the memory buffer after CP, 
in a manner similar to the I command.  Thus, if the command
.sp
.ti 8
RMACRO<cr>
.sp
is issued by the operator, ED reads from the file MACRO.LIB until 
the end-of-file and automatically inserts the characters into the 
memory buffer.
.pp
ED also includes a block move facility implemented through the 
X (Transfer) command.  The form
.sp
.ti 8
nX
.sp
transfers the next n lines from the current line to a temporary 
file called
.sp
.ti 8
X$$$$$$.LIB
.sp
which is active only during the editing process.  You can
reposition the current line reference to any portion of 
the source file and transfer lines to the temporary file.  The 
transferred lines accumulate one after another in this file and 
can be retrieved by simply typing
.sp
.ti 8
R
.sp
which is the trivial case of the library read command.  In this 
case, the entire transferred set of lines is read into the memory 
buffer.  Note that the X command does not remove 
the transferred lines from the memory buffer, although a K 
command can be used directly after the X, and the R command does 
not empty the transferred LIB file.  That is, given that a set of 
lines has been transferred with the X command, they can be 
reread any number of times back into the source file.  The 
command
.sp
.ti 8
0X
.sp
is provided to empty the transferred line file.
.pp
Note that upon normal completion of the ED 
program through Q or E, the temporary LIB file is removed.  If ED 
is aborted with a CTRL-C, the LIB file will exist if lines have 
been transferred, but will generally be empty (a subsequent ED 
invocation will erase the temporary file).
.sp 2
.tc         2.1.9  Repetitive Command Execution
.sh
2.1.9  Repetitive Command Execution
.qs
.pp
The macro command M allows you to group ED commands 
together for repeated evaluation.  The M command takes the following form:
.sp
.nf
.ti 8
n M CS <cr>
or
.ti 8
n M CS ^Z
.sp
.fi
where CS represents a string of ED commands, not including 
another M command.  ED executes the command string n times if 
n>1.  If n=0 or 1, the command string is executed repetitively 
until an error condition is encountered (for example, the end of the 
memory buffer is reached with an F command).
.pp
As an example, the following macro changes all occurrences of 
GAMMA to DELTA within the current buffer, and types each line 
that is changed:
.sp
.ti 8
MFGAMMA^Z-5DIDELTA^Z0TT<cr>
.sp
or equivalently
.sp
.ti 8
MSGAMMA^ZDELTA^Z0TT<cr>
.sp 2
.tc    2.2  ED Error Conditions
.he CP/M Operating System Manual             2.2  ED Error Conditions
.sh
2.2  ED Error Conditions
.qs
.pp
On error conditions, ED prints the message BREAK X AT C where X 
is one of the error indicators shown in Table 2-4.
.bp
.ce
.sh
Table 2-4.  Error Message Symbols
.sp
   Symbol                         Meaning
.sp
.ll 62
.in 15
.ti -10
?         Unrecognized command.
.sp
.ti -10
>         Memory buffer full (use one of the commands D, K, N, S, 
or W to remove characters); F, N, or S strings too long.
.sp
.ti -10
#         Cannot apply command the number of times specified 
(for example, in F command).
.sp
.ti -10
O         Cannot open LIB file in R command.
.in 0
.ll 65
.sp 2
If there is a disk error, CP/M displays the following message:
.sp
.ti 8
BDOS ERR on d: BAD SECTOR
.sp
You can choose to ignore the error by pressing RETURN
at the console (in this case, the memory buffer data
should be examined to see if they were incorrectly read), or you
can reset the system with a CTRL-C and reclaim the back-up file
if it exists.  The file can be reclaimed by first typing the
contents of the BAK file to ensure that it contains the proper
information.  For example, type the following:
.sp
.ti 8
TYPE x.BAK
.sp
where x is the file being edited.  Then remove the primary file
.sp
.ti 8
ERA x.y
.sp
and rename the BAK file
.sp
.ti 8
REN x.y=x.BAK
.sp
The file can then be reedited, starting with the previous 
version.
.pp
ED also takes file attributes into account.  If you
attempt to edit a Read-Only file, the message
.sp
.ti 8
** FILE IS READ/ONLY **
.sp
appears at the console.  The file can be loaded and examined, but 
cannot be altered.  You must end the edit 
session and use STAT to change the file attribute to R/W.  If 
the edited file has the system attribute set, the following message:
.sp
.ti 8
'SYSTEM' FILE NOT ACCESSIBLE
.sp
is displayed and the edit session is aborted.  Again, the STAT 
program can be used to change the system attribute, if desired.
.sp 2
.tc    2.3  Control Characters and Commands
.he CP/M Operating System Manual 2.3  Control Characters and Commands
.sh
2.3  Control Characters and Commands
.qs
.pp
Table 2-5 summarizes the control characters and 
commands available in ED.
.sp 2
.ce
.sh
Table 2-5.  ED Control Characters
.sp
.ll 60
.nf
    Control                        Function
    Character
.sp
.fi
.in 20
.ti -16
CTRL-C          System reboot
.sp
.ti -16
CTRL-E          Physical <cr><lf> (not actually entered 
in command)
.sp
.ti -16
CTRL-H          Backspace
.sp
.ti -16
CTRL-J          Logical tab (cols 1, 9, 16, ...)
.sp
.ti -16
CTRL-L          Logical <cr><lf> in search and
substitute strings
.sp
.ti -16
CTRL-R          Repeat line
.sp
.ti -16
CTRL-U          Line delete
.sp
.ti -16
CTRL-X          Line delete
.sp
.ti -16
CTRL-Z          String terminator
.sp
.ti -16
rub/del         Character delete
.sp
.in 0
.ll 65
.pp
Table 2-6 summarizes the commands used in ED.
.sp 2
.ce
.sh
Table 2-6.  ED Commands
.sp
.nf
    Command                        Function
.ll 60
.fi
.sp
.in 20
.ti -16
  nA            Append lines
.sp
.ti -16
  +\b_B            Begin or bottom of buffer
.sp
.ti -16
  +\b_nC           Move character positions
.sp
.ti -16
  +\b_nD           Delete characters
.sp
.ti -16
  E             End edit and close files (normal end)
.sp
.ti -16
  nF            Find string
.bp
.in 0
.ll 65
.ce
.sh
Table 2-6.  (continued)
.sp
    Command                        Function
.ll 60
.in 20
.sp
.ti -16
  H             End edit, close and reopen files
.sp
.ti -16
  I             Insert characters, use i if both upper
and lower-case characters are to be entered.
.sp
.ti -16
  nJ            Place strings in juxtaposition
.sp
.ti -16
  +\b_nK           Kill lines
.sp
.ti -16
  +\b_nL           Move down/up lines
.sp
.ti -16
  nM            Macro definition
.sp
.ti -16
  nN            Find next occurrence with autoscan
.sp
.ti -16
  O             Return to original file
.sp
.ti -16
  +\b_nP           Move and print pages
.sp
.ti -16
  Q             Quit with no file changes
.sp
.ti -16
  R             Read library file
.sp
.ti -16
  nS            Substitute strings
.sp
.ti -16
  +\b_nT           Type lines
.sp
.ti -16
  +\b_U            Translate lower- to upper-case if U, 
no translation if -U
.sp
.ti -16
  +\b_V            Verify line numbers, or show 
remaining free character space
.sp
.ti -16
  0V            A special case of the V command, OV, 
prints the memory buffer statistics in the form
.sp
free/total
.sp
where free is the number of free bytes in the memory buffer (in 
decimal) and total is the size of the memory buffer
.sp
.ti -16
  nW            Write lines
.sp
.ti -16
  nZ            Wait (sleep) for approximately n 
seconds
.sp
.ti -16
  +\b_n            Move and type (+\b_nLT).
.in 0
.ll 65
.sp
.pp
Because of common typographical errors, ED requires several 
potentially disastrous commands to be typed as single letters, 
rather than in composite commands.  The following commands:
.sp
.nf
.in 3
o E(end)
o H(head)
o O(original)
o Q(quit)
.fi
.in 0
.sp
must be typed as single letter commands.
.pp
The commands I, J, M, N, R, and S should be typed as i, j, m, n, 
r, and s if both upper- and lower-case characters are used in the 
operation, otherwise all characters are converted to upper-case.  
When a command is entered in upper-case, ED automatically 
converts the associated string to upper-case, and vice versa.
.sp 2
.ce
End of Section 2
.nx threea




