Copyright (c) Hyperion Entertainment and contributors.

Difference between revisions of "AmigaOS Manual: AmigaDOS Using the Editors"

From AmigaOS Documentation Wiki
Jump to navigation Jump to search
 
(17 intermediate revisions by 2 users not shown)
Line 17: Line 17:
 
The bottom line of the ED window is the status line used for displaying messages, prompts, and commands. Error messages displayed on the status line remain until you enter another ED command. Figure 4-1 illustrates the ED window showing the status line.
 
The bottom line of the ED window is the status line used for displaying messages, prompts, and commands. Error messages displayed on the status line remain until you enter another ED command. Figure 4-1 illustrates the ED window showing the status line.
   
Figure 4-1. ED Window with Status Line
+
[[File:DosFig4-1.png|none|frame|ED Window with Status Line]]
  +
  +
== Starting ED ==
  +
  +
Start ED from a Shell or with the Workbench Execute Command menu item. Open ED at the prompt by entering ED and a new or existing file name, as follows:
  +
  +
1> ED <filename>
  +
  +
where <filename> is the name of an existing file or a new file to be used for saving your work. If the file name specified cannot be found in the current directory, ED opens a blank window and displays the message Creating new file.
   
 
The format for ED is the following:
 
The format for ED is the following:
   
<nowiki>ED [FROM] <filename> [SIZE <n>] [WITH <filename>] [WINDOW <window specification>] [TABS <n>] [WIDTH | COLS <n>] [HEIGHT | ROWS <n>]</nowiki>
+
<nowiki>ED [FROM] <filename> [SIZE <n>] [WITH <filename>]
  +
[WINDOW <window specification>] [TABS <n>] [WIDTH | COLS <n>]
  +
[HEIGHT | ROWS <n>]</nowiki>
   
 
The FROM argument specifies the source file to be edited. This argument is required, but the FROM keyword is optional.
 
The FROM argument specifies the source file to be edited. This argument is required, but the FROM keyword is optional.
Line 38: Line 48:
   
 
The WIDTH and HEIGHT arguments adjust the size of the ED window by specifying the number of characters to display horizontally and vertically. By default the ED window is 640 x 200 picels or approximately 88 characters wide by 21 lines high.
 
The WIDTH and HEIGHT arguments adjust the size of the ED window by specifying the number of characters to display horizontally and vertically. By default the ED window is 640 x 200 picels or approximately 88 characters wide by 21 lines high.
 
== Starting ED ==
 
 
Start ED from a Shell or with the Workbench Execute Command menu item. Open ED at the prompt by entering ED and a new or existing file name, as follows:
 
 
1> ED <filename>
 
 
where <filename> is the name of an existing file or a new file to be used for saving your work. If the file name specified cannot be found in the current directory, ED opens a blank window and displays the message Creating new file.
 
   
 
== Using ED ==
 
== Using ED ==
Line 182: Line 184:
 
ED has two sets of command menu assignments: default and expanded. The default menu assignments, as illustrated in Figure 4-2, are set up by the S:Ed-startup file, which is automatically executed each time you run ED. The S:Ed-startup file is a command file of ED extended mode commands, without the Escape characters. You can edit this file to set up custom menus, as described on page 4-21, or define preprogrammed function key assignments with the Set FN Key menu item.
 
ED has two sets of command menu assignments: default and expanded. The default menu assignments, as illustrated in Figure 4-2, are set up by the S:Ed-startup file, which is automatically executed each time you run ED. The S:Ed-startup file is a command file of ED extended mode commands, without the Escape characters. You can edit this file to set up custom menus, as described on page 4-21, or define preprogrammed function key assignments with the Set FN Key menu item.
   
Figure 4-2. Default Menu Assignments
+
[[File:DosFig4-2.png|none|frame|Default Menu Assignments]]
   
 
=== Enabling Expanded Menus ===
 
=== Enabling Expanded Menus ===
Line 188: Line 190:
 
The expanded command menu assignments, as illustrated in Figure 4-3, can be enabled by renaming or deleting the default S:Ed-startup file. If ED cannot find a file named S:Ed-startup, it opens with the expanded set of menus, providing more options.
 
The expanded command menu assignments, as illustrated in Figure 4-3, can be enabled by renaming or deleting the default S:Ed-startup file. If ED cannot find a file named S:Ed-startup, it opens with the expanded set of menus, providing more options.
   
Figure 4-3. Expanded Menu Assignments
+
[[File:DosFig4-3.png|none|frame|Expanded Menu Assignments]]
   
 
Rather then deleting your S-Ed-startup file, we recommend that you rename it as follows:
 
Rather then deleting your S-Ed-startup file, we recommend that you rename it as follows:
Line 567: Line 569:
 
This script produces the menus illustrated in Figure 4-4:
 
This script produces the menus illustrated in Figure 4-4:
   
Figure 4-4. ED Custom Menu Example
+
[[File:DosFig4-4.png|none|frame|ED Custom Menu Example]]
   
 
== Printing From ED ==
 
== Printing From ED ==
Line 715: Line 717:
 
The line at the bottom of the MEmacs screen identifies either the current file name or the name of the current buffer if no file name is specified. Figure 4-5 illustrates the MEmacs opening screen .
 
The line at the bottom of the MEmacs screen identifies either the current file name or the name of the current buffer if no file name is specified. Figure 4-5 illustrates the MEmacs opening screen .
   
Figure 4-5. MEmacs Opening Screen
+
[[File:DosFig4-5.png|none|frame|MEmacs Opening Screen]]
   
 
Several buffers can be in use at the same time and one or more can be displayed on the screen simultaneously. Menu options switch between them. At all times, the screen displays what is actually in the buffer.
 
Several buffers can be in use at the same time and one or more can be displayed on the screen simultaneously. Menu options switch between them. At all times, the screen displays what is actually in the buffer.
Line 785: Line 787:
 
Figure 4-6 illustrates the MEmacs expanded menu bar.
 
Figure 4-6 illustrates the MEmacs expanded menu bar.
   
Figure 4-6. MEmacs Expanded Menus
+
[[File:DosFig4-6.png|none|frame|Expanded Menus]]
   
 
=== Project Menu ===
 
=== Project Menu ===
Line 1,054: Line 1,056:
   
 
Keys are bound when they can be used to perform a function. For example, any key or key sequence that can be used as a shortcut for a menu item is bound to that menu item.
 
Keys are bound when they can be used to perform a function. For example, any key or key sequence that can be used as a shortcut for a menu item is bound to that menu item.
  +
  +
{| class="wikitable"
  +
| Describe Key || Esc,<br/>Ctrl+D || Tells you if any functions are bound to a key or key sequence. At the prompt enter the specific key or key sequence.
  +
|-
  +
| Bind Key || Esc,<br/>Ctrl+B || Allows you to bind a key to a function. At the prompt, enter the key or key sequence.
  +
|-
  +
| Unbind Key || Esc,<br/>Ctrl+U || Allows you to return a bound key to an unbound state. At the prompt, enter the key or key sequence. Standard bound keys cannot be unbound.
  +
|-
  +
| Echo || Esc,<br/>Ctrl+E || Displays the string entered in the command line.
  +
|-
  +
| Move to Edge of Window || Shift+Arrow || Moves the cursor to the top, bottom, left, or right edge of the screen.
  +
|-
  +
| Delete the Next Character || Ctrl+D || Deletes the character at the current position. Same as pressing Del.
  +
|-
  +
| Delete the Previous Character || Ctrl+H || Deletes the character to the left of the current cursor position. Same as pressing Backspace.
  +
|-
  +
| Move to Next Line || Ctrl+M || Inserts a newline character after the current cursor position and moves the cursor to the start of the new line.
  +
|-
  +
| Move x number of Characters || Ctrl+F,<br/>Ctrl+B || Allows you to move the cursor forward or backward a specified number of spaces. Providing no value moves the cursor only one character.
  +
|}
  +
  +
== Customizing MEmacs ==
  +
  +
MEmacs looks for an Emacs_pro file when it is opened to see if there are any command or local files that it should automatically execute. You can customize the Emacs_pro file by adding commands to it that you use often, command sequences, or text strings. If an Emacs_pro file does not already exist, you can create one.
  +
  +
To create a global file of commands, place the Emacs_pro file in the S: directory. Local files can be out in any directory. If that directory is the current directory when MEmacs is opened, the commands in that particular local file are executed.
  +
  +
When both local and global Emacs_pro files are present, the local file overrides the global file.
  +
  +
For example:
  +
  +
Set Case On
  +
Set-Key F11 "Dear Sirs:"
  +
Set-Key F12 "^S Workbench"
  +
Set-Key F13 "^X^B"
  +
  +
makes the following assignments:
  +
  +
{| class="wikitable"
  +
| Shift+F1 || Enter the text string "Dear Sirs:".
  +
|-
  +
| Shift+F2 || Search forward for the next occurrence of the word Workbench. (The Set Case On commands make any text searches case-sensitive.)
  +
|-
  +
| Shift+F3 || Display the list of buffers.
  +
|}
  +
  +
You must use Ctrl+Q to enter a Ctrl+key sequence. For example, to enter the ^S character shown in the example, press Ctrl+Q, Ctrl+S.
  +
  +
== Quitting MEmacs ==
  +
  +
You can exit MEmacs by selecting the Quit menu item in the Project menu or by entering Ctrl+C. MEmacs lets you save any modified buffers or quit without saving.
  +
  +
= EDIT =
  +
  +
EDIT is a line editor designed for the automated editing of files, particularly binary files or files that are larger than available memory. You cannot create a new file with EDIT.
  +
  +
EDIT processes files line by line. As EDIT moves through the input, or source file, each line is passed after alteration to a sequential output file, the destination file.
  +
  +
EDIT processes the lines in files in a forward direction; however, you can move backward a limited number of lines. EDIT holds the lines in an output queue before writing them to the destination file. The size of this queue depends on the amount of memory available. You can increase the size of the queue with the OPT P and OPT W options.
  +
  +
The format for EDIT is the following:
  +
  +
EDIT [FROM] <filename> [[TO] <filename>] [WITH <filename>] [VER <filename>]
  +
[OPT P <lines> | W <chars> | P<lines>W<chars>] [WIDTH <chars>] [PREVIOUS <lines>]
  +
  +
The FROM argument specifies the source file to be edited. You must specify a source file with EDIT, although the FROM keyword is optional.
  +
  +
The TO argument specifies the destination file to which EDIT sends its output, including editing changes. If you omit the TO argument, EDIT uses a temporary file. This temporary file is renamed with the name of the FROM file and overwrites the FROM file when editing is complete.
  +
  +
The WITH keyword specifies a file containing editing commands.
  +
  +
The VER keyword specifies the file to which EDIT sends error messages and line verifications. If the VER argument is not given, EDIT uses the screen.
  +
  +
Use OPT P <n> and OPT W <n> to specify the PREVIOUS and WIDTH options. However, do nit use the OPT keyword with PREVIOUS and WIDTH.
  +
  +
You can use the PREVIOUS and WIDTH options to increase or decrease the amount of available memory. The PREVIOUS option sets the number of previous lines available to EDIT to the integer <n>. The WIDTH option sets the maximum number of characters allowed on a line to <n>. EDIT multiples the number of previous lines by the maximum number of characters (PREVIOUS * WIDTH) to determine the available memory. The default values are PREVIOUS 40 WIDTH 120.
  +
  +
== Starting EDIT ==
  +
  +
Start EDIT through a Shell using the following command:
  +
  +
1.< EDIT <filename>
  +
  +
Where <filename> is the name of an existing file to be edited.
  +
  +
== EDIT Commands ==
  +
  +
The following list provides background information about EDIT commands:
  +
  +
{| class="wikitable"
  +
| Current line || Refers to the line that EDIT is working on at any time. Every command entered refers to the current line, all text changes are made to the current line, and new lines are inserted before the current line.
  +
|-
  +
| Original lines || The lines of the source file. Lines retain their original number until you renumber them with the REWIND or = commands.
  +
|-
  +
| Non-original lines || Any lines that are inserted into the source file or original lines that are split. These are not assigned line numbers.
  +
|-
  +
| Line verification || When using commands that change information in a line, EDIT displays the revised line after the command is executed.
  +
|-
  +
| Arguments || Strings, qualified strings, numbers, and switch values used with EDIT commands.
  +
|}
  +
  +
Enter commands in one of the following three ways:
  +
  +
* Enter the commands, then press Return
  +
* Enter the final command argument, then press Return
  +
* Enter a semicolon or closing parenthesis
  +
  +
The text conventions used in the command description are the following:
  +
  +
* Command names are shown in upper case, although EDIT is not case-sensitive.
  +
* Angle brackets indicate that information must be substituted. For example, <string> indicates that the command takes a string argument.
  +
* An <n> represents a numeric argument.
  +
* Square brackets indicate that the argument is optional. For example, [<n>] indicates that the command can take an optional numeric argument.
  +
* Slashes are used as delimiters for strings; use one slash between two strings.
  +
* Periods are used as delimiters for file names (slashes cannot be used since they are used to separate strings).
  +
  +
== Selecting the Current Line ==
  +
  +
The following commands let you move through the file and select the current line.
  +
  +
{| class="wikitable"
  +
| Move to a specific line number || M <n> || Specify a new current line by entering its line number, a period, and an asterisk as M's argument. Only original lines can be accessed by line number.
  +
|-
  +
| Move to next line in the source file || N || Move forward one line. Entering a number and N indicates the number of lines to move forard. When used as the last line of the source file, EDIT creates an extra line at the end of the file. If you are already on this extra line, using N causes an error message to be displayed.
  +
|-
  +
| Move to the previous line in the source file || P || Moves back one line. Entering P repeatedly moves more than one line. Entering a number + P indicates how many lines to move back. You can only move back to previous lines that have not yet been written to the destination file. The default is 40 lines, which can be changed with the PREVIOUS option.
  +
|-
  +
| Find || F<string> || Lets you select a current line by specifying some of its content.
  +
|-
  +
| Search Backward || B,F<string> || Looks backward starting from the current line through the source file for a line containing the specified string.
  +
|}
  +
  +
== Editing the Current Line ==
  +
  +
The following commands add new material or replace material on the current line.
  +
  +
{| class="wikitable"
  +
| Insert <string2> after <string1> || A <string1> <string2> || Insert <string2> after the first occurrence of <string1>.
  +
|-
  +
| Insert <string2> before <string1> || B <string2> <string1> || Insert <string2> before the first occurrence of <string1>.
  +
|-
  +
| Exchange <string2> for <string1> || E <string2> <string1> || Replaces the first occurrence of <string1> with <string2>.
  +
|}
  +
  +
== Inserting and Deleting Lines ==
  +
  +
The following commands insert new material (non-original lines) and delete lines from the source file. You can also insert complete files into the source file.
  +
  +
{| class="wikitable"
  +
| Insert one or more lines || I [<n>] || If given alone or with a line number, inserts text before the current line.<br/>
  +
If given with an asterisk, the text is inserted at the end of the file.<br/>
  +
Indicate the end of the insertion by pressing Return, Z, and Return.
  +
|-
  +
| Delete one or more lines || D [<n>] || Deletes the current line if entered with no arguments. Deletes a specific line if entered with a line number. Deletes a set of lines if entered with a range of line numbers; do not use punctuation between the numbers. Deletes everything from the current line through the end of the source file of entered with a period and an asterisk as arguments.
  +
|-
  +
| Delete all lines until the specified string is found || D,F<string> || Deletes successive lines from the source file until the line containing the matching string is found. If no argument is specified, it deletes all lines until it finds the last string specified.
  +
|-
  +
| Delete existing lines and replace with new text || R [<n>] || Lets you delete line and then insert new ones. Entering a line number following R indicates a specific line to replace.
  +
|-
  +
| Change the terminator || Z <string> || Tells EDIT that it has reached the end of any new text that is being inserted. Entering a string after Z changes it from the default.
  +
|-
  +
| Show current information about EDIT || S,H,D || Displays saved information values, such as the last string searched for, the last command entered, and the input terminator.
  +
|-
  +
| Turn trailing spaces on/off || <nowiki>T,R,+|-</nowiki> || Preserves any blanks that fall at the end of lines.
  +
|}
  +
  +
== Editing Line Windows ==
  +
  +
You can define subsections of the line, called line windows, on which EDIT executes all subsequent commands. In the descriptions of EDIT qualifiers, the beginning of the line always indicates the beginning of the line window.
  +
  +
Whenever EDIT verifies a current line, it indicates the position of the line window by displaying a > character directly beneath the line. EDIT omits the pointer if the line window begins at the start of the line.
  +
  +
The following commands control the position of the character pointer:
  +
  +
{| class="wikitable"
  +
| > || Moves the pointer one character to the right.
  +
|-
  +
| < || Moves the pointer one character to the left.
  +
|-
  +
| PR || Resets the pointer to the start of the line.
  +
|-
  +
| PA <string> || Moves the pointer to the first character after the specified string.
  +
|-
  +
| <string> || Moves the pointer to the first character before the specified string.
  +
|}
  +
  +
The following commands change the character at the current pointer, then move the pointer.
  +
  +
{| class="wikitable"
  +
| $ || Makes the character at the pointer lower case, then moves the pointer one character to the right.
  +
|-
  +
| % || Makes the character at the pointer upper case, then moves the pointer one character to the right.
  +
|-
  +
| _ || The _ (underscore) command deletes the character at the pointer, turning it into a space, then moves the pointer one character to the right.
  +
|-
  +
| # || Deletes the character at the pointer, then moves the rest of the line one character to the left. To delete several characters, specify a number before the #. For example, 5# deletes the next five characters in the window.
  +
|}
  +
  +
A combination of these commands can be used to edit a line character by character.
  +
  +
The following commands insert and exchange text on the current line, similar to the A, B, and E commands; however, the character pointer is moved on completion.
  +
  +
{| class="wikitable"
  +
| Insert <string2> after <string1> || A,P <string1> <string2> || Inserts <string2> after the first occurrence of <string1>. The pointer is then positioned after <string2>.
  +
|-
  +
| Insert <string2> before <string1> || B,P <string1> <string2> || Inserts <string2> before the first occurrence of <string1>. The pointer is then positioned after <string2>.
  +
|-
  +
| Exchange <string1> with <string2> || E,P, <string1> <string2> || Replaces the first occurrence of <string1> with <string2>. The pointer is then positioned after <string2>.
  +
|-
  +
| Delete Till After || D,T,A <string> || Deletes all text from the beginning of the line or the character pointer to the end of the specified string.
  +
|-
  +
| Delete Till Before || D,T,B <string> || Deletes all text from the beginning of the line or the character pointer; stops before the specified string.
  +
|-
  +
| Delete From After || D,F,A <string> || Deletes all text starting after a specified string to the end of the line.
  +
|-
  +
| Delete From Before || D,F,B <string> || Deletes all text starting with the specified string to the end of the line.
  +
|}
  +
  +
== Splitting and Joining Lines ==
  +
  +
These commands split a line into more than one line and join together two or more successive lines.
  +
  +
{| class="wikitable"
  +
| Split line before <string> || S,B <string> || Splits the current line before the specified string. The first part of the line is sent to the output queue; the second part is made into a new non-original current line. Qualifiers can be used to restrict the context of the string.
  +
|-
  +
| Split line after <string> || S,A <string> || Splits the current line after the specified string. The first part of the line is sent to the output queue; the remainder of the line becomes the new current line. Qualifiers can be used to restrict the context of the string.
  +
|-
  +
| Join two lines || C,L [<string>] || Joins the current line with the next line of the source file. The string argument is optional; however, if a string is specified it is added to the end of the current line and that whole line is joined with the next line in the source file.
  +
|}
  +
  +
== Renumbering Lines ==
  +
  +
These commands renumber the source file's lines to include non-original lines and to update a file that has been edited.
  +
  +
{| class="wikitable"
  +
| Renumber source lines || = <n> || Sets the current line number to <n>. All subsequent original and non-original lines below <n> are renumbered you move to them.
  +
|-
  +
| Return to the beginning source file || REWIND || Moves back through the source file to make line 1 the current line. EDIT scans the rest of the source file and writes the lines to the destination file. This file is closed and reopened as a new source file. Non-original lines are now recognized as original lines. Can be entered as REWI.
  +
|}
  +
  +
== Verifying Lines ==
  +
  +
These commands describe different ways of verifying lines.
  +
  +
{| class="wikitable"
  +
| Turn Verification on/off || V + <nowiki>|</nowiki> - || Turns line verification on or off. If off, the lines are not displayed on the screen. To turn off, enter V -. To turn on, enter V +.
  +
|-
  +
| Verify the current line || ? || Verifies the current line by displaying the line number and the contents of the line.
  +
|-
  +
| Verify the current line with character indicators || ! || Produces two lines of verification. In the first line all non-graphic characters are replaced with the first character of their hexadecimal value In the second line, a minus sign is displayed under all positions corresponding to upper case letters and the second hexadecimal digit corresponds to non-graphic characters. All other positions contain spaces. In binary files, non-graphic characters are represented with question marks (??).
  +
|}
  +
  +
== Inspecting the Source File ==
  +
  +
These commands advance through the source file, sending the lines it passes to the verification file, as well as to the normal output. They are known as Type commands because they display lines on the screen.
  +
  +
{| class="wikitable"
  +
| Type <n> lines to the screen || T <n> || Types the specified number of lines to the screen. The first line typed is the current line. Omitting the <n> continues typing to the end of the source file. Interrupt the command with Ctrl+C.
  +
|-
  +
| Type the lines in the output queue || T,P || Displays the lines currently held in the output queue.
  +
|-
  +
| Type until EDIT has replaced all the lines in the output queue || T,N || Types from the current line forward until all the lines in the output queue are replaced. The previous contents are sent to the destination file.
  +
|-
  +
| Type with line numbers || T,L <n> || Similar to the T command. Types a specified number of lines, displaying the line numbers. EDIT displays + + + + for inserted or split lines since they do not have line numbers.
  +
|}
  +
  +
== Making Global Changes ==
  +
  +
These commands start and stop global changes. Global changes take place automatically as EDIT scans the source file in forward direction. These commands automatically apply an A, B, or E command, as appropriate, to any occurrence of <string1> in a new current line. They also apply to the current line that is in effect when the command is given.
  +
  +
GA [qualifier] <string1> <string2>
  +
GB [qualifier] <string1> <string2>
  +
GE [qualifier] <string1> <string2>
  +
  +
For example, if you want to change DF0: to DF2: throughout an entire file, enter:
  +
  +
GE /DF0:/DF2:/
  +
  +
{| class="wikitable"
  +
| Cancel a global command || CG [<id number>] || Cancels a global command. The identification number set with a GA, GB, or GE command is output to the verification file or the serene if EDIT is interactive. If no argument is specified, all global operations are cancelled. To cancel a specific operation, enter the identification number of the CG command.
  +
|-
  +
| Suspend a global command || SG [<id number>] || Suspends a global command. All global operations are suspended if no argument is given. Enter the identification number to suspend a specific operation.
  +
|-
  +
| Enable a global command || EG [<id number>] || Resumes global operation that had been suspended with the SG command. Unless a specific identification number is provided, all global commands are resumed.
  +
|-
  +
| Show global commands || SHG || Displays the current global commands and their identification numbers. Also provides the number of times each global string was matched.
  +
|}
  +
  +
== Changing Command, Input, and Output Files ==
  +
  +
These commands change the files set up when you started EDIT from the Shell. These files are:
  +
  +
* the command file - started with the WITH option.
  +
* the input file - the source file specified with FROM.
  +
* the output file - the destination file specified with TO.
  +
  +
{| class="wikitable"
  +
| Changing the Command File || C <filename> || Reads EDIT commands from a specified file. Delimit the file using a character other than a slash (/) since AmigaDOS uses these characters to separate file names. When all commands in the specified file are executed, the file is closed. You can then enter the commands through the keyboard.
  +
|-
  +
| Changing the Input File || FROM <filename> || Reads lines from another source file. EDIT does not close the original source file. Reselect the source file by entering the FROM command without an argument. For example of the FROM command, see page 4-54.
  +
|-
  +
| Closing a File || CF <filename> || Closes the destination file that was originally specified with the TO command. You can then open that file for input. CF can also close a new input file that is open. For examples of the CF command, see page 4-54.
  +
|-
  +
| Changing the Output File || TO <filename> || Specifies a different file as the destination file. The TO command writes the existing queue of output lines to the new TO file. The new TO file is used until another file is specified. Reselect the original destination file by using the TO command with no argument. The alternate output file remains open, but unused. For examples of the TO command, see page 4-54.
  +
|-
  +
| Stop executing the command file || Q || Stops EDIT from executing the current command file specified with the WITH keyword or with the C command. EDIT reverts to any previous command file. Using Q at the outermost level is equivalent to using the W command.
  +
|}
  +
  +
The FROM, CF, and TO commands are used as follows:
  +
  +
{| class="wikitable"
  +
! Command !! Action
  +
|-
  +
| M10 || Pass lines 1-9 in the original source file to the output queue.
  +
|-
  +
| FROM .XYZ. || Select the XYZ file for new input; line 10 of the original source file remains current.
  +
|-
  +
| M6 || Pass line 10 from the original file, then pass lines 1-5 from the XYZ file to the output queue. Line 6 of XYZ is the new current line.
  +
|-
  +
| FROM || Reselect the original source file.
  +
|-
  +
| M14 || Pass line 6 from XYZ, then lines 11-13 from the original source file to the output queue. Line 14 of the source file is the new current line.
  +
|-
  +
| FROM .XYZ. || Reselect file XYZ. Line 14 of the source file is still the current line.
  +
|-
  +
| M* || Pass line 14 of the source file and all remaining lines of file XYZ to the output queue. An extra line is added to the end of file XYZ. That line is the new current line.
  +
|-
  +
| FROM || Reselect the original source file. The extra line added to file XYZ is still the current line.
  +
|-
  +
| CF .XYZ. || Close file XYZ.
  +
|-
  +
| M* || Pass the remaining lines of the source file (lines 15 to the end of the file) to the output queue.
  +
|-
  +
| M11 || Pass lines 1-10 of the source file to the original destination file.
  +
|-
  +
| TO .XYZ. || Make XYZ the new output file.
  +
|-
  +
| M21 || Pass lines 11-20 to file XYZ.
  +
|-
  +
| TO M31 || Make the original destination file current, and pass lines 21 to 30 to it.
  +
|-
  +
| TO .XYZ. || Make XYZ the current output file.
  +
|-
  +
| M41 || Pass lines 31 to 40 to XYZ.
  +
|-
  +
| TO || Make the original destination file current.
  +
|-
  +
| TO .XYZ. || Send the output queue to file XYZ.
  +
|-
  +
| 1000N || Advance through the next 1000 lines of the source file.
  +
|-
  +
| TO || Select the original destination file.
  +
|-
  +
| CF .XYZ. || Close the XYZ file.
  +
|-
  +
| I2000 .XYZ. || Insert the 1000 lines from the source file that were sent to file XYZ back into the source file above line 2000.
  +
|}
  +
  +
== Ending EDIT ==
  +
  +
These commands exit EDIT.
  +
  +
{| class="wikitable"
  +
| Exit, saving changes || W || Exits EDIT, saving all changes to the destination file specified by TO. EDIT exits after reaching the end of the source, closing all the files, and relinquishing memory. If you started EDIT without specifying a destination file, it renames the temporary destination with the same name as the original source file, which is renamed. T/Edit-backup. This backup is only available until the next time you run EDIT.
  +
|-
  +
| Exit, without saving changes || STOP || Stops EDIT immediately without saving any changes to the source file. Prevents EDIT from overwriting to original source file, ensuring that no changes are made to the original input information.
  +
|}

Latest revision as of 16:09, 31 January 2021

A text editor or word processing program is necessary for creating or editing text files and script files. Amiga Workbench software comes with three text editors. This chapter describes them in the following order:

  • ED
  • MEmacs
  • EDIT

Each of the Amiga editors can be used separately for editing AmigaDOS scripts and programs; ED and MEmacs can be used for creating these files. If you are comfortable with the UNIX Emacs editor, you may prefer using the MEmacs editor. If you need to edit files containing binary code or you need to edit files too large to fit into memory, use EDIT. If you are not familiar with any of the editors, we recommend that you use the ED editor.

Each editor has the basic functionality of a word processor, however, none of these editors support style formatting options, such as italics, page numbering, or different fonts. If you need these features, you can purchase third party word processing software containing such features for your Amiga.

ED

ED is a full screen ASCII text editor that uses menus and function keys to access its features. It is easy to use and is suitable for editing scripts, startup files, MountLists, and other simple files. Use either a mouse or the keyboard to perform operations with ED. Although ED's menus are preprogrammed, when you are familiar with the program, you can reconfigure them as needed.

Note
ED does not accept files containing binary code. To edit this type of file, use EDIT or MEmacs.

The bottom line of the ED window is the status line used for displaying messages, prompts, and commands. Error messages displayed on the status line remain until you enter another ED command. Figure 4-1 illustrates the ED window showing the status line.

ED Window with Status Line

Starting ED

Start ED from a Shell or with the Workbench Execute Command menu item. Open ED at the prompt by entering ED and a new or existing file name, as follows:

1> ED <filename>

where <filename> is the name of an existing file or a new file to be used for saving your work. If the file name specified cannot be found in the current directory, ED opens a blank window and displays the message Creating new file.

The format for ED is the following:

ED [FROM] <filename> [SIZE <n>] [WITH <filename>]
 [WINDOW <window specification>] [TABS <n>] [WIDTH | COLS <n>]
 [HEIGHT | ROWS <n>]

The FROM argument specifies the source file to be edited. This argument is required, but the FROM keyword is optional.

The SIZE argument changes the ED buffer size. ED has a default text buffer size of 40,000 bytes. For example:

1> ED Script SIZE 55000

increase the size of the buffer to 55,000 bytes.

The WITH argument specifies an ED command file that can contain any sequence of ED extended mode commands. When WITH is specified, ED executes the commands contained in the command file. The WITH argument's keywords is required if you use WITH.

The WINDOW argument specifies the console type, such as RAX:0/0/640/256/EdWindow or CONSOLE:. The WINDOW argument's keyword is required if you use WINDOW.

TABS sets the tab stop interval, which is the number of spaces to the right that the cursor moves when you press the Tab key. The default value for TABS is 3.

The WIDTH and HEIGHT arguments adjust the size of the ED window by specifying the number of characters to display horizontally and vertically. By default the ED window is 640 x 200 picels or approximately 88 characters wide by 21 lines high.

Using ED

All ED commands have key sequences and many are available through menus. You can enter ED commands in either of the following ways:

  • By choosing the command's menu item.
  • By typing in the command's key sequence and pressing Return.

In addition, you can use the mouse to perform some commands, such as those that control cursor movement.

You can work on files in ED with the following two command modes:

Immediate
Commands are executed as soon as typed. EP opens in immediate mode.
Extended
Commands are not executed until you press Return or Esc.

Immediate Commands

In immediate mode, ED executes commands right away. Specify an immediate command by pressing a single key or Ctrl+key combination or by using the mouse. All immediate commands have corresponding extended versions.

Immediate commands control the following:

  • Cursor movement
  • Text scrolling
  • Text insertion
  • Text deletion
  • Repetition of commands

Moving the Cursor in Immediate Mode

The cursor can be positioned anywhere in text by moving the pointer to the desired spot and clicking the selection button. To move the cursor with the keyboard, use the arrow keys, Tab, and Ctrl+key combinations.

Note
In ED, the Tab key only moves the cursor. It does not insert Tab characters or spaces in a line.

Move the cursor one position in any direction by pressing the appropriate arrow key. If the cursor is on the right edge of the screen, ED scrolls the text to the left do display the rest of the line. ED scrolls the text vertically one line at a time and horizontally ten characters at a time. You cannot move the cursor beyond the left edge of the line. If you try to move the cursor beyond the top or bottom of the file, ED displays a Top of File or Bottom of File message.

Additional key combinations that control cursor movement are:

Shift+up arrow Top of the file.
Shift+down arrow Bottom of the file.
Shift+left arrow Left edge of the ED window (regardless of the margin setting).
Sift+right arrow End of the current line.
Ctrl+] Right edge of current line (if cursor is already there, it is moved to the left edge).
Ctrl+E Start of the first line on the screen (if cursor is already there, it is moved to the end of the last line on the screen).
Ctrl+T Start of the next word.
Ctrl+R Space following the previous word.
Tab The next tab position (multiple of the TABS value; 3 by default).

If your file has more lines than can fit in the ED window, you can scroll through the file vertically. Scroll one line at a time by pressing the up or down cursor key to move in the corresponding direction. Move the text in jumps by pressing:

Ctrl+D Moves 12 lines down through the file.
Ctrl+U Moves 12 lines up through the file.

These commands do not move the cursor position in the window; they redraw the text in the window with the new line at the cursor position.

If something disturbs your screen, such as an alert from another program appearing in the ED window or message remarks in the status line, press:

Ctrl+V Refreshes the window display.

Inserting Text in Immediate Mode

Any characters typed in immediate mode are inserted at the current cursor position and the cursor is shifted to the right. Any characters to the right of the cursor are shifted to make room for new text. If the line is wider than the width of the window, the window scrolls to the right to show what you are typing. If you move the cursor beyond the end of the line, ED inserts spaces between the end of the line and any new characters inserted.

There is maximum limit of 255 characters in a line. If you add more characters, ED displays a Line Too Long message.

To split the current line at the cursor, press Return. Any text to the left of the cursor remains on the original line. All text under and to the right of the cursor moves down onto a new line. Pressing Return at the end of the line creates a new blank line.

Deleting Text in Immediate Mode

ED has no type over mode. To replace a word or line, you must delete the existing words and insert new information with the following keys and key combinations:

Backspace Deletes the character to the left of the cursor.
Del Deletes the character highlighted by the cursor.
Ctrl+O If the cursor is over a space, all spaces up to the next character are deleted. If the cursor is over a character, all characters up to the next space are deleted.
Ctrl+Y Deletes all characters from the cursor to the end of the line.

When text is deleted, any characters remaining on the line shift to the left and any text beyond the right edge of the screen becomes visible.

Changing Case in Immediate Mode

You can change the case of text by positioning the cursor and pressing Ctrl+F. If the letter is lower case, it becomes upper case and vice versa. Ctrl+F does not change non-alphabetic characters or symbols.

After you press Ctrl+F, the cursor moves to the right. You can hold down Ctrl+F to repeat the command until you change all the letters on the line.

Extended Commands

In extended mode, commands are displayed on the command line - or status line - at the bottom of the window. ED does not execute these commands until you press Return or Esc. If you use Esc to execute extended commands, ED remains in extended mode. If you use Return to execute extended commands, ED returns to immediate mode.

Extended commands manage the following:

  • Program control
  • Cursor movement
  • Text modification
  • Block control
  • Searching and exchanging text

To enter extended mode, press Esc. An asterisk appears as a prompt in the status line. Extended commands consist of one or two characters. Multiple extended commands can be typed on a single command line by separating them with a semicolon. Commands can be grouped together for ED to repeat automatically. Use Backspace to correct mistakes.

You can also execute commands through the programmable menu and function keys. Reconfigure the menus and functions keys by assigning a command to the key or menu item of your choice as described on page 4-21.

Using String Delimiters

In some cases, commands require arguments, such as a number or a text strig. A string argument for an ED command must be enclosed in a pair of identical delimiter characters. In unambiguous situations you may omit the trailing delimiter. Valid delimiters include ", /, \, !, :, +, -, and %. You cannot use the same delimiter character inside your string. Invalid delimiter characters include letters, numbers, spaces, semicolons, question marks, brackets, and control characters.

Using a File Requester

You can also ask ED to use a file requester, allowing you to view the contents of the drives and directories in your system.

To invoke a file requester for a load or save command, you must place a question mark (?) before the required string argument. Be sure to include a space before the question mark (for example, sa ?/Text/). Normally, when a command is followed by a string. ED treats the string as the file to be loaded or saved and attempts the operation immediately. However, the question mark indicates that you want to specify the file through a file requester. You must still specify a string after the question mark, but the string becomes the text that appears in the file requester title bar.

ED Menus

ED has two sets of command menu assignments: default and expanded. The default menu assignments, as illustrated in Figure 4-2, are set up by the S:Ed-startup file, which is automatically executed each time you run ED. The S:Ed-startup file is a command file of ED extended mode commands, without the Escape characters. You can edit this file to set up custom menus, as described on page 4-21, or define preprogrammed function key assignments with the Set FN Key menu item.

Default Menu Assignments

Enabling Expanded Menus

The expanded command menu assignments, as illustrated in Figure 4-3, can be enabled by renaming or deleting the default S:Ed-startup file. If ED cannot find a file named S:Ed-startup, it opens with the expanded set of menus, providing more options.

Expanded Menu Assignments

Rather then deleting your S-Ed-startup file, we recommend that you rename it as follows:

  1. In the Workbench window, go to the Window menu and select Show All Files.
  2. Double-click on the S drawer icon.
  3. Click on the Ed-startup icon.
  4. Go to the Icons menu and choose Rename.
  5. Delete the name in the Rename requester's New Name text gadget and enter a new name for Ed-startup.
  6. Select OK.

You can also create your own customized file of startup options. Avoid including Quit commands in the S:Ed-startup file since they can cause ED to quit immediately after opening.

The menu items in both the default and expanded menus have the same function regardless of which set you use. All of the ED commands are available through the keyboard using extended mode commands even if they do not appear in any menu.

The following sections describe the menu items found in the expanded menus and their corresponding extended and immediate mode commands. An ellipsis (...) indicates that an argument is required or that a menu item opens a requester or prompt.

Project Menu

The following are the expanded Project menu items:

New Esc,N,W Creates a new file, replacing the existing file. The message Edits will be lost-type Y to confirm: is displayed. Press any key (except Y) to abort the command.
Open... Esc,O,P... Opens a file. Specify the file by entering the path to the file as a properly delimited string. (If slashes appear in the path to a file, do not use the slash as a delimiter.) The message Edits will be lost-type Y to confirm: reminds you that you are replacing the current file.
Insert File... Esc,I,F... Inserts a file into the current file. ED reads into memory the specified file at the point immediately following the current line.
Write Block... Esc,W,B... Writes the currently marked block to a specified file. ED overwrites any other files with that name and copies the block to the file.
Save Esc,S,A Saves the text to the current file, overwriting the existing text in the file. Use Save As to save to different file. SA followed by Q is equivalent to the X command.
Save As... Esc,S,A... Saves the text to the specified file name.
Save & Exit Esc,X Exits ED, saving the current file to the designated file name. ED writes the text it is holding in memory to the file that was specified when ED was opened and then terminates.
About Esc,S,H Shows the current state of the editor. The screen display information, such as the value of tab stops, current margins, block marks, and the name of the file being edited.
Quit Esc,Q Exits ED without saving changes. If you made any changes to the file, ED asks if you want to quit. If you press Y, ED terminates immediately without saving the changes to the file.

Edit Menu

The following are commands used for editing:

Undo Line Esc,U Reverses changes made to the current line. However, ED cannot undo a line deletion. Once you have moved from the current line, the U command cannot undo a change.
Star Block Esc,B,S Identify the beginning and end of a block of text. To specify a block of text to be moved, inserted, or deleted, place the cursor on the first line that you want in the block and enter the BS command. Move the cursor to the last line that you want in the block and enter the BE command.
You cannot start or finish a block in the middle of a line.
Show Block Esc,S,B Redraws the display so the block is at the top of the screen.
Insert Block Esc,I,B Inserts a copy of the block after the current line. The block remains defined until you change the text. Use IB to insert copies of the block throughout the document.
Delete Block Esc,D,B Deletes a block.
Delete Line Esc,D
Ctrl+B
Deletes the entire line.

Movement Menu

The following commands move the cursor around the screen:

Top Esc,T Top of the file; first line of the file is brought to the top of the window.
Bottom Esc,B Bottom of the file; last line of the file is brought to the bottom of the window.
Go To Line... Esc,M... Move the cursor to the specified line. Enter the line number on the status line and press Return. The line specified is brought to the top of the window. If no number is given, the cursor goes to the top of the window.
Next Page Esc,P,D
Ctrl+D
Go to next page.
Previous Page Esc,P,U
Ctrl+U
Go to previous page.

Search Menu

The following commands let you search through the file for specific instances of text. You can substitute one pattern of text with another (search and replace) and have ED request confirmation of (query) each replace. If the specified text is not found or there are no more instances of the text, the message Search failed is displayed. When using the Find and Replace menu commands, ED prompts for the text strings. Enter the text without delimiters. When using extended mode, include delimited strings with the command.

Find...
Find Next
Esc,s... Finds the next occurrence of the specified string of text. The search starts one character beyond the current cursor position and continues forward through the file. If the string is found, the cursor moves to the start of the located string. The search is case-sensitive, unless the Ignore Case command is used. Find Next repeats the command.
Reverse Find...
Reverse Find
Next
Esc,B,F... Searches backwards through the file for the specified string. This command finds the last occurrence of the string before the current cursor position. The search continues through to the beginning of the file. Reverse Find Next repeats the command.
Replace... Esc,E... Exchanges one occurrence of text with another.
In extended mode, enter the strings enclosed by three delimiters. For example, to replace the word to with too, enter "to"too". Specify empty strings by typing two delimiters with nothing between them. If the first string is empty, ED inserts the second string at the current cursor position. If the second string is empty, ED searches for the next occurrence of the first string and then deletes it. Note that ED ignores margin settings when exchanging text.
Global Replace Esc,R,P,E... Exchanges all occurrences of text.
Query-Replace... Esc,E,Q... Searches for the text to be exchanged and requests verification by displaying Exchange?. Enter Y to exchange or another other key to abort.
Global Query-Replace... Esc,R,P,E,Q... Searches for all occurrences of the text to be exchanged and requests verification for each. Enter Y to exchange or any other key to abort.

Settings Menu

The following commands are used for setting up your ED environment:

Set FN Key... Esc,S,F... Defines the function keys and other programmable keys. Defining function key and Ctrl+key commands is similar to defining menu items. See page 4-15 for instructions for defining function keys and an example of the Set FN Key command.
Show FN Key... Esc,D,F
<key>
Displays the setting for the function key specified by <key>. Enter a space and a key slot number for <key>.
Reset Keys Esc,R,K Resets the key definitions to the default. See page 4-16 for a table of special key mappings.
Right Margin... Esc,S,R... Sets the right margin. Use the SR command followed by a number indicating the column position.
Left Margin... Esc,S,L... Sets the left margin. Use the SL command followed by a number indicating the column position. The left margin should not be set beyond the right edge of the screen.
Ignore Case Esc,U,C Specifies a case-insensitive search. UC instructs all subsequent searches not to make any distinction between upper and lower case next. To make searches case-sensitive again, use the LC command.
Case Sensitive Esc,L,C Specifies a case-sensitive search.

Set FN Key

Set FN Key is used to define function keys and other programmable keys. There are 57 immediate command key slots ranging from 1 to 57. Any slot number can be redefined and any numbers within the range that do not appear in the special key mappings on page 4-16 are not defined.

The following is the syntax for the Set FN Key command:

SF <slot number> /command string/

Define Ctrl+key combinations by substituting a caret (^) and the other character for the slot number.

Example Script

This example script assigns function keys to cursor control commands. You can also enter these as a series of extended mode commands. The Top of File, Bottom of File, End of Page, Next Page, Next Line, and Previous Line commands are assigned to the F1 through F6 keys, respectively. Quotation marks are used as delimiters.

SF 1 "t"
SF 2 "b"
SF 3 "ep"
SF 4 "pd"
SF 5 "n"
SF 6 "p"

Special Key Mappings

The following table shows the default key definitions used in the Reset Keys command:

Slot# Key/Key Sequence Function
1-10 F1 through F10 Not defined
11-20 Shift+F1 to Shift+F10 Not defined
21 Shift+left arrow Move to beginning of line
22 Shift+right arrow Move to end of line
23 Shift+up arrow Move to top of document
24 Shift+down arrow Move to bottom of document
25 Del Delete character at cursor
26 Not defined Not defined
27 Ctrl+A Insert line
28 Ctrl+B Delete line
29 Ctrl+C Not defined
30 Ctrl+D Move down 12 lines
31 Ctrl+E Move to top or bottom of screen
32 Ctrl+F Change case
33 Ctrl+G Repeat last extended command line
34 Ctrl+H Delete character left of cursor
35 Ctrl+I Move cursor to next tab position
36 Ctrl+J Not defined
37 Ctrl+K Not defined
38 Ctrl+L Not defined
39 Ctrl+M Return
40 Ctrl+N Not defined
41 Ctrl+O Delete word or spaces
42 Ctrl+P Not defined
43 Ctrl+Q Not defined
44 Ctrl+R Move to end of previous word
45 Ctrl+S Not defined
46 Ctrl+T Move start of next word
47 Ctrl+U Move up 12 lines
48 Ctrl+V Redisplay window
49 Ctrl+W Not defined
50 Ctrl+X Not defined
51 Ctrl+Y Delete to end of line
52 Ctrl+Z Not defined
53 Ctrl+[ Esc (enter extended command mode)
54 Not defined Not defined
55 Ctrl+] Move to end or start of line, depending on cursor position
56 Not defined Not defined
57 Not defined Not defined

Command Menu

The following commands are for manipulating files:

Extended Command... Esc,C,M... Enters extended command mode; equivalent to pressing Ctrl+[ or Esc.
Repeat Last Esc,R,E Attempts to repeat the last command.
Run File... Esc,R,F... Loads and executes a command file of extended mode commands.
ARexx Command... Esc,R,X... Runs the specified ARexx program.
Redisplay Esc,V,W Redraws the ED window and clears the status line; equivalent to pressing Ctrl+V.

Other ED Commands

There are also ED commands that do not appear in menus. These commands are listed here in functional groups. Use them in extended mode by entering the following key sequences.

Program Control

The following are program control commands:

Extend Margins Esc,E,X Extends the margins for the current line. Once you enter the EX command, ED ignores the right margin on the current line.
Status Line Message Esc,S,M... Prints a given string on the status line.
Exit with Query Esc,X,Q Exits ED unless changes were made to the file. If changes have been made, the message File has been changed-type Y to save and exit: is displayed. Press any key (except Y) to abort the exit. XQ is equivalent to clicking the close gadget on the ED window.

Cursor Control

The following commands are used for controlling the cursor:

End Page Esc,E,P End of a page.
Previous Esc,P Start of the previous line.
Character Left Esc,C,L One place to the left.
Character Right Esc,C,R One place to the right.
Current End Esc,C,E End of the current line.
Current Start Esc,C,S Start of the current line.
Tab Esc,T,B Next tab position.
Word Next Esc,W,N Start of the next word.
Word Previous Esc,W,P Space after previous word.

Modifying Text

The following commands edit text on the screen:

Insert Before Esc,I Inserts the specified string on the line before the cursor. Specify a new line's string after the I command to insert text before the current line containing the cursor.
Insert After Esc,A Inserts the specified string on the line after the cursor. This command works in the same way as I, except that the string is inserted on a new line beneath the current cursor position.
Split Esc,S Splits the current line at the cursor position.
Join Esc,J Joins the next line to the end of the current line.
Delete Esc,D Deletes the current line.
Delete Character Esc,D,C Deletes the character under the cursor.
Delete Left Esc,D,L Deletes the character to the left of the cursor.
Delete Word Esc,D,W Deletes to the end of the current word.
End Line Esc,E,L Deletes to the end of the current line.
Flip Case Esc,F,C Switches the case of the selected letters, one at a time.
Set Tab Esc,S,T Sets the tab stop. To change the current setting of tabs, use the ST command followed by a number.
Next Esc,N Start of the next line.

Repeating Commands in Extended Mode

Pressing Ctrl+G repeats a command line. You can set up execute complex sets of editing commands many times.

You can repeat a command a specified number of times by entering the number before the command. For example:

4 E/rename/copy/

exchanges the next four occurrences of "rename" to "copy".

Use the RP (Repeat) extended command to repeat a command until ED returns an error, such as reaching the end of the file. For example:

T;RP E/rename/copy/

moves the cursor to the top of the file, then exchanges all occurrences of "rename" with "copy". The T command (Top of File) changes all occurrences of Rename in the whole file. Otherwise, only the occurrences after the current cursor position are changed.

To execute command groups repeatedly, you can group the commands together in parentheses. You can also nest command groups. For example:

RP (F/Workbench/;3A//)

inserts three blank lines (the null string//) after every line containing Workbench.

To interrupt any sequence of extended commands, press any key during execution. If an error occurs, ED abandons the command sequence.

Customizing ED

You can customize ED with commands that change the menus and function key setup. These commands can be entered individually within ED. They can also be saved as a script, such as S:Ed-startup, or as a file specified using the WITH argument. To execute the file from within ED, use the Run File (Esc,R,F) extended command. For information about changing the function keys, see page 4-15.

\ Set Menu Item || Esc,S,I || Defines the menu headings and items. There are 120 menu item slots ranging from 0 to 119. The slot type identifies the contents of the slot and is a number from 0 to 4. The 0 slot type must be the last defined slot. Do not create a menu without items; if you specify a menu heading, include menu items after it. See below for the syntax of the Set Menu Item command and a table of the slot types.
Enable Menu Esc,E,M Enables menus. You must follow the Set Menu Item commands with EM to enable the menu commands. See page 4-22 for an example script using the Enable Menu command.

Set Menu Item

The following is the syntax for the Set Menu Item command:

SI <slot number> <slot type> /string1/string2/

The following table shows the slot types and functions used with the Set Menu Item command:

Type Function String Input
0 End of Menus No arguments
1 Menu Heading String1 = heading name
2 Menu Item String1 = item name
String2 = command string
3 Submenu Heading String1 = heading name
String2 = command string
4 Separator bar No arguments

Example Script

The following is an example script using the Set Menu Item and Enable Menu commands. Quotation marks are used as the delimiters.

SI 0 1 "Project"
SI 1 2 "Open . . . " "op ? /Open file:/"
SI 2 2 "Save ... " "sa"
SI 3 4
SI 4 2 "Quit!" "q"
SI 5 1 "Move"
SI 6 2 "Top" "t"
SI 7 2 "Bottom" "b"
SI 8 0
EM

This script produces the menus illustrated in Figure 4-4:

ED Custom Menu Example

Printing From ED

Use the following steps to print a file that is open in the current ED window:

  1. Choose the Save As menu item to display a file requester.
  2. Enter prt: in the Drawer field.
  3. Select OK.

This prints the file, but does not save it to disk. If you wish to save the file you must select the Save menu item or Save As and a file name.

Quitting ED

You can exit ED in one of the following three ways:

  • Esc,X. This method exits ED and saves the current file to a designated file name that was specified when ED was opened.
  • Esc,X,Q or click on the ED window's close gadget. This method exits ED if no changes were made to the file. If changes were made to the file, ED lets you save the changes or exit without saving.
  • Esc,Q or select the Quit item in the Project menu. This method exits ED without saving any changes if you confirm the status line warning that changes will be lost.

ARexx Support

You can also control ED from ARexx by sending and receiving commands through ED's ARexx port. Each copy of ED running concurrently has an individual ARexx port name that must be specified to handle information for the correct session. The ARexx port names are assigned as follows:

  • The first session's port name is ED
  • The second session's is ED_1
  • The third session's is Ed_2 and so on

Many of ED's extended commands can be used from ARexx. By using ED's RV command in ARexx programs, you can send information from ED to ARexx. This gives information about the status of ED, such as the current line number of the name of the file being edited.

The RV command accepts the name of the ARexx stem variable to store its argument information. For example, in ARexx:

address 'Ed' 'RV /stem/'

assigns values to the following variables:

stem.LEFT Current left margin
stem.RIGHT Current right margin
stem.TABSTOP Current tab stop setting
stem.LMAX Maximum number of lines visible on screen
stem.WIDTH Width of the screen in characters
stem.X Cursor X position in the ED window (1 is the left edge)
stem.Y Cursor Y position in the ED window (1 is the top line)
stem.BASE Window base (normally 0, but non-zero when the screen is shifted to the right)
stem.EXTEND Extended margin value (Extend Margins command)
stem.FORCECASE Case sensitivity flag (Ignore Case = 1, Case Sensitive = 0)
stem.LINE Current line number in the file (1 is the first line)
stem.FILENAME Name of the file being edited
stem.CURRENT Text of the current line
stem.LASTCMD Last extended command issued
stem.SEARCH Lst string searched for

Any valid ARexx symbol can be substituted for "stem". Enclose the name in proper delimiters. These variables can be treated as ordinary ARexx stem variables.

ED/ARexx Example Program

The example program, Transpose.ed, illustrates the use of several extended commands from ARexx. This program transposes two characters when launched from ED. For example, if a line contains the string 123 and the cursor is highlighted the 3, Transpose.ed changes the string to 213.

Enter this program and save it as REXX:Transpose.ed. Then, open ED and edit an existing file or create a new one. Place the cursor one character to the right of the ones to be transposed, press Esc, and enter:

RX /transpose.ed/

The program executes and the characters are transposed if ARexx is running and everything is entered correctly. The entire file name, including the extension, must be specified to run the program.

/*Transpose.ed: An example program to transpose two characters. */
/*Given string '123', if cursor is on 3, this macro converts */
/*string into '213'. */
HOST = address () /*find out which ED session invoked this program*/
address VALUE HOST /*...and talk to that session */
'rv''/CURR/' /*Ask ED to store info in stem variable CURR */
             /*Obtain two pieces of information: */
currpos = CURR.X /*1.position of cursor on line */
currling = CURR.CURRENT /*2. Contents of current line */
if /currpos >2) then /*Work only on the current line */
  currpos = currpos - 1
else do /*Otheriwse, report error and exit */
'sm/Cusor must be at position 2 or further to the right/'
exit 10
end
 
/*Next the code needs to reverse the CURRPOSth and CURRPOSth-1 */
/*characters and then replace the current line with the new one. */
/*drop CURR. CURR is no longer needed; dropping it saves some */
/*memory. */
'd' /*Tell ED to delete current line */
currlin = swapch (currpos,currlin) /*Swap the two characters */
'i/'||currlin||'/' /*Insert modified line */
do i = 1 to currpos /*Place cursor back where it started */
  'cr' /*ED's `cursor right' command */
  end
exit /*Program has finished */
 
/*Function to swap two characters */
Swapch: procedure */
parse arg cpos,clin
  ch1 = substr(clin,cpos1) /*Get character */
  clin = delstr(clin,cpos1) /*Delete it from string */
  clin = insert(ch1,clin,cpos-2,1) /*Insert to create transposition */
return clin /*Return modified string */

MEmacs

MEmacs (MicroEmacs), which is similar to the UNIX-based Emacs editor, is a screen-oriented editor in which you can edit multiple files at the same time. MEmacs performs all operations on memory-resident text, requiring that entire text files be able to fit into memory at once.

Line length, generally 80 characters long, is limited to the right edge of the screen. You can enter characters beyond the limit, however, they are not displayed. To see these characters, break the line or delete some of the displayed characters. A dollar sign ($) at the right edge of the screen indicates that there are characters beyond what is displayed.

The format for the MEmacs command is the following:

MEMACS [<filename>] [GOTO <n>] [OPT W]

The <filename> argument is optional.

The GOTO <n> option specifies the line on which the cursor is to appear when the file is opened.

Specifying OPT W opens MEmacs in a Workbench window rather than on its own screen, which saves memory.

Starting MEmacs

MEmacs can be run from either the Workbench or the Shell. From the Workbench, double-click on the MEmacs icon in the Tools window of the Extras disk. If you have a hard disk, the Tools drawer is in your Workbench window.

From the Shell, enter:

MEmacs <filename>

where <filename> specifies the file to read into MEmacs. If a file with that name does not previously exist, a new file is created when you save your work.

MEmacs Commands

The line at the bottom of the MEmacs screen identifies either the current file name or the name of the current buffer if no file name is specified. Figure 4-5 illustrates the MEmacs opening screen .

MEmacs Opening Screen

Several buffers can be in use at the same time and one or more can be displayed on the screen simultaneously. Menu options switch between them. At all times, the screen displays what is actually in the buffer.

MEMacs has two conditions of operation:

Normal
When you enter and manipulate text directly in the file without special functions.
Command
When you enter a command through a menu selection or the keyboard shortcut for it. In the command condition, the cursor jumps to the bottom line of the display and waits for you to supply additional information following the prompt. You cannot return to the normal condition until you satisfy or cancel the command by pressing Return.

In the MEmacs normal condition, you can:

  • Move the cursor using the arrow keys.
  • Move the cursor to the edge of the window by holding down Shift and pressing the appropriate arrow key.
  • Move the cursor by clicking the left mouse button at the desired place on the screen.
  • Insert characters at the current cursor position by typing them.
  • Delete the character at the current cursor position by pressing Del.
  • Delete the character to the left of the cursor by pressing Backspace.
  • Perform other special menu and command functions.

When using MEmacs, you should be familiar with the following special terms:

Buffer
A memory area that MEmacs controls. There is always at least one buffer used by MEmacs containing zero or more text characters.
Dot
The current cursor position.
Mark
A specified cursor position. (Each buffer has its own dot and mark.) The Set-mark menu item marks the current cursor position (described on page 4-33). You can move forward or backward in the file, adding or deleting text. To return to the marked place, select the Swap-dot&mark menu item (described on page 4-36).
You can also set a mark to indicate the beginning of a block of text that you want to duplicate, move, or delete. The block encompasses all the characters starting with the mark and continuing to the current cursor position.
Kill
Kill commands remove text from the screen to save in a kill buffer. This text can be retrieved and inserted into your document by using the Yank command. Issuing successive Kill commands (without selecting Yank in between) adds each block of the text to the existing text in the kill buffer. If you select Yank, the next block of killed text otherwise the current block.
Window
MEmacs screens can be split into multiple layers for editing and displaying more than one buffer or two or more portions of the same buffer. Each layer is a MEmacs window.
Modified Buffers
Buffers are marked as modified when any changes are made. The modified status is removed when the buffer is saved.
To see modified buffers, use the List-buffers command (described on page 4-33); modified buffers are identified with an asterisk (*). If you exit MEmacs without saving any changes, a prompt tells you that modified buffers exist and asks if you really want to quit.

Menu Commands

MEmacs has the following menus:

Project Contains system and file-oriented items.
Edit Contains buffer editing commands.
Window Controls the characteristics of the MEmacs windows.
Move Controls the placement of the cursor.
Line Controls line-oriented operations.
Word Controls word-oriented operations.
Search Controls search and search/replace options.
Extras Controls the numerical value of arguments and lets you execute a series of operations as though it were a single special command.

Figure 4-6 illustrates the MEmacs expanded menu bar.

Expanded Menus

Project Menu

The commands in the Project menu, except for Visit-file, affect the buffer associated with the current cursor position.

Rename Ctrl+X,F Changes the name of the file associated with the current buffer. Pressing Return without specifying a file name disassociates the buffer from any file name.
Read-file Ctrl+X,
Ctrl+R
Replaces the contents of the current buffer with the contents of a file. Enter a complete file path. Press Return without specifying a file name to ignore the request and return to normal mode.
Visit-file Ctrl+X,
Ctrl+V
Allows you to work with additional files other than the one you are currently editing. Enter the complete file path.
Insert-file Ctrl+X,
Ctrl+I
Insert the contents of a file into the current buffer at a point one line above the current cursor position. Enter the complete file path.
Save-file Ctrl+X,
Ctrl+S
Writes the contents of the current buffer to the file name associated with that buffer. Issues the file's line count following a successful save. MEmacs does not save the file if no name is provided; it displays this error message: No file name.
Save-as-file Ctrl+X,
Ctrl+W
Allows you to specify the name and path of a file associated with a buffer.
Save-mod Ctrl+X,
Ctrl+M
Writes the contents of all modified buffers to the disk. Do not accidentally modify a buffer that you did not intend to change.
Save-exit Ctrl+X,
Ctrl+F
Saves all modified buffers and exits MEmacs.
New-Cli Ctrl+- Opens a new Shell window known as a Spawn Window. Enter AmigaDOS commands in the Spawn Window without interfering with MEmacs. Close the window with ENDSHELL.
Cli-Command Ctrl+X,! Lets you execute an AmigaDOS command while in MEmacs. Enter a command following the ! prompt at the bottom of the screen. Command output is placed in the spawn.output buffer.
Quit Ctrl+C Exits MEmacs. You are given an opportunity to save modified buffers or quit without saving. Alternative keyboard shortcuts: Ctrl+X,Ctrl+C Esc,Ctrl+C.
About... Gives program copyright information

Edit Menu

The commands in the Edit menu affect the editing of your buffers and their associated files.

Kill-region Ctrl+W Deletes block of text from the current buffer and saves them in a kill buffer. Text can be retrieved with the Yank command. Make copies of a block by immediately selecting Yank without changing the cursor position after killing the block. This restores the block to its position and leaves a copy in the kill buffer.
Yank Ctrl+Y Copies the contents of the kill buffer to the current cursor location on the current line. Reverses the action of Kill-region without changing the contents of the kill buffer. Used with Kill-region for moving text or for repeatedly copying a single block of text.
Set-mark Ctrl+@ Marks the cursor position in a buffer. The subsequent cursor position is referred to as a dot. Move between the mark and the dot using the Swap-dot&mark command in the Move menu. Used for marking blocks of text. Alternative keyboard shortcut: Esc,-.
Copy-region Esc,W Copies the contents of the marked region to the kill buffer without deleting it, replacing any previous contents.
Upper-region Ctrl+X,
Ctrl+U
Changes the text of the entire marked region to upper case.
Lower-region Ctrl+X,
Ctrl+L
Changes the text of the entire marked region to lower case.
List-buffers Ctrl+X,
Ctrl+B
Splits the current buffer's window and displays a list of the buffers MEmacs is maintaining. To redisplay the current buffer, select the One-window command or press Ctrl+X,1. The List-Buffer fields are:
C Displays an asterisk if the buffer has been modified since it was last saved to a file. (Stands for changed.)
Size Shows how many characters are in the buffer.
Buffer Shows the name given to the buffer. If you read in a file, this is the name of the file without the full path.
File Shows the full path to the file. This is the file to which MEmacs writes the buffer if you Save-file or Save-exit while the cursor is in that buffer.
Select-buffer Ctrl+X,B Allows you to select the buffer to edit in the current window. Replaces the contents of the window with the selected buffer or new buffer.
Insert-buffer Esc,
Ctrl+Y
Insert the contents of a named buffer into the current buffer at the line above the current cursor position.
Kill-buffer Ctrl+X,K Deletes the contents of one or more chosen buffers, returning the memory to the memory manager to reuse. You must specify the buffer to be deleted; a buffer cannot be killed if its contents are currently displayed.
Justify-buffer Ctrl+X,J Removes all blank spaces and tabs from the left edge of all the lines in the current buffer. The text realigns with the current margins.
Redisplay Ctrl+L Redraws the screen.
Quote-char Ctrl+Q Allows insertion of any literal character in the text file, except the Tab key. Alternative keyboard shortcut: Ctrl+X,Q.
Indent Ctrl+J Moves the cursor to the next line, automatically indenting the same amount of spaces as the previous line. Alternative keyboard shortcuts: Help or Enter on the numeric keypad.
Transpose Ctrl+T Swaps the positions of two adjacent characters. Place the cursor on the right-most of the two characters and execute the command.
Cancel Ctrl+G Ends an ongoing menu command, such as query search and replace.

Window Menu

The Window menu controls how to view your buffers on the screen.

One-window Ctrl+X,1 Makes the current buffer a single, full-sized window on the MEmacs screen.
Split-window Ctrl+X,2 Splits the current window in half, positioning the current buffer identically in both windows. Any changes you make in either window affect the whole buffer.
Next-window Ctrl+X,N Moves the cursor to the next window and makes that window available for editing.
Prev-window Ctrl+X,P Moves the cursor to the previous window and makes that window available for editing.
Expand-window Ctrl+X,Z Adds a line to the height of the current window and simultaneously subtracts a line from the height of the adjacent window.
Shrink-window Ctrl+X,
Ctrl+Z
Substracts a line from the height of the current window and adds a line to the height of the adjacent window.
Next-w-page Esc,
Ctrl+V
Displays the next page of the adjacent window. This does not make the window available for editing.
Prev-w-page Ctrl+X,V Displays the previous page of the adjacent window. If only one window is displayed, it displays the previous page of that window.

Move Menu

These commands move the cursor rapidly through the current buffer.

Top-of-buffer Esc,< Moves the cursor to the top line of the current buffer.
End-of-buffer Esc,> Moves the cursor to the bottom line of the current buffer.
Top-of-window Esc,, Moves the cursor to the top of the current window.
End-of-window Esc,. Moves the cursor to the bottom of the current window.
Goto-line Ctrl+X,
Ctrl+G
Moves the cursor to a specified line number. Specifying a line number larger than the total number of lines in a buffer moves the cursor to the last line of the buffer.
Swap-dot&mark Ctrl+X,
Ctrl+X
Marks the current cursor position (dot) and moves the cursor to the previously marked setting.
Next-page Ctrl+V Moves the cursor toward the end of the buffer by one full window, less one line.
Prev-page Esc,V Moves the cursor towards the beginning of the buffer by one full window, less one line.
Next-word Esc,F Moves the cursor forward to the next non-alphabetic character, such as a space or punctuation mark, following the current word.
Previous-word Esc,B Moves the cursor back to the first letter of the previous word.
Scroll-up Ctrl+Z Moves the text up one line.
Scroll-down Esc,Z Moves the text down one line.

Line Menu

These commands move the cursor within or between lines and perform operations involving entire lines.

Open-line Ctrl+O Splits the line containing the cursor, forcing the character at the current cursor position to become the first character of the following line. The cursor remains on the original line. Pressing the Del key cancels an accidental Open-line.
Kill-line Ctrl+X,
Ctrl+D
Deletes the line containing the cursor and places the text in the kill buffer.
Kill-to-eol Ctrl+K Deletes the text between the current cursor position and the end of the line and places the text in the kill buffer.
Start-of-line Ctrl+A Moves the cursor to the first position on a line.
End-of-line Ctrl+E Moves the cursor to the last position on a line.
Next-line Ctrl+N Moves the cursor down one line.
Previous-line Ctrl+P Moves the cursor up one line.
Line-to-top Esc,! Moves the line containing the cursor to the top of the window.
Delete-blanks Ctrl+X,
Ctrl+O
Deletes blank lines, proceeding forward from the current cursor position until MEmacs reaches the next line on which there is text. Does not delete single blank lines.
Show-Line# Ctrl+X,= Displays information on the present cursor position.

Word Menu

The Word menu contains word-associated operations.

Delete-forw Esc,D Deletes the character on which the cursor is positioned and all remaining characters to the right until the next non-alphanumeric character is found, such as a blank space, tab, or punctuation.
Delete-back Esc,H Delets all characters to the left of the cursor until it finds the first character of a word. The character at the cursor position is not deleted. Alternative keyboard shortcut: Esc,Del.
Upper-word Esc,U Changes a word to upper case, starting at the cursor position and proceeding to the last character of the word.
Lower-word Esc,L Changes a word to lower case, starting at the cursor position and proceeding to the last character of the word.
Cap-word Esc,C Changes the character at the cursor position to upper case. Also changes the characters to the right of the cursor, up to the end of the word, to lower case.
Switch-case Esc,^ Changes the case of a word, starting at the current cursor position and proceeding to the right until it reaches the end of the word. If a word is upper case or has mixed text, it changes upper to lowr case and vice versa.

Search Menu

These commands search through the current buffer for specific text strings. The case (upper or lower) of the string is not significant in the search. However, if you are using text substitution (search and replace), the text is replaced in the case of the replacement string.

Search-forward Ctrl+S Searches through the text starting at the current cursor position and moving forward to the end of the buffer. At the prompt, enter the character string for the search. Alternative keyboard shortcut: Ctrl+X,S.
Search-backward Ctrl+R Searches through the text from the current cursor position backwards to the beginning to the buffer. Alternative keyboard shortcut: Ctrl+X,R.
Search-replace Esc,R Searches the same as Search-forward, allowing you to replace the string with different text. At the prompt, enter the replacement string of characters.
Query-s-r Esc,Q Operates the same as Search-replace, except it asks for confirmation to replace each time it finds the specified string. The options are Y (yes), N (no), C (change all occurrences), and Ctrl+G (abort).
Fence-match Esc,
Ctrl+F
Finds the closest occurrence of the fence character to match the one at the current cursor position. Fence characters are parenthesis, brackets, braces, and angle brackets.

Extras Menu

These commands are MEmacs operational commands and macro commands. Specific numeric arguments may be required before selecting a command; an * indicate that an argument is required. Macro commands are executed by selecting the Execute-macro menu item.

Set-arg Ctrl+U Lets you specify a numeric argument for a command.
Set Esc,S Lets you set the following MEmacs parameters:
Screen Places the MEmacs display in a Workbench window or back onto a custom screen.
Interlace Turns the interlace mode on or off.
Mode Results in a second prompt "Mode:"; you can enter Cmode (for editing C programs) or Wrap (to enable automatic word-wrap when the text reaches a set cursor position). Cmode provides automatic fence matching. Use +mode or -mode to add or subtract a mode.
Left Determines the left margin. Prompts for a numerical argument if not provided with the entry.
Right Determines the right margin. Prompts for a numerical argument if not provided with the entry.
Tab Sets the increment for tab spacing. Prompts for a numerical argument if not provided with the entry.
Indent Determines how far to indent each level of nesting (used in Cmode). Prompts for a numerical argument if not provided with the entry.
Case Turns case-sensitive searches on of off; default is off.
Backup Turns the MEmacs backup function on or off. Your options are: ON (renames the current file <filename>.bak and saves that bakkup file to the T: directory); SAFE (this option checks to see if a file already exists for the buffer - if so, it displays an error and does not overwrite the existing file, Ctrl+X clears the display); and OFF (this is the default option - MEmacs does not perform any backup).
Start-macro Ctrl+X,( Tells MEmacs to start recording any subsequent keystrokes. Used with the Stop-macro and Execute-macro commands.
Stop-macro Ctrl+X,) Tells MEmacs to stop recording keystrokes.
Execute-macro Ctrl+X,E Repeats keystrokes that were entered between Start-macro and Stop-macro.
Set-key Ctrl+X,
Ctrl+K
Allows you to redefine all of the function keys, the Shifted function keys, the Help key, or any key on the numeric keypad as keyboard macros. You cannot use the menu shortcut of Ctrl+@ to insert the Set-mark command into any keyboard macro definitions.
Reset-keys Esc,K Returns any keys defined by Set-keys to their original default state.
Execute-file Esc,E Allows you to execute a program file within MEmacs.
Execute-line Ctrl+[,
Ctrl+[
Sets MEmacs to command mode. At the prompt enter any menu command and its parameters. Alternate keyboard shortcut: Esc,Esc.

The following table contains the default values of the Set-key/function keys when used in macro commands.

Key Assignment Key Sequence
F1 Clone line Ctrl+A,Ctrl+K,Ctrl+Y,Ctrl+M,Ctrl+Y
F2 Delete line Ctrl+X,Ctrl+D
F3 Execute keyboard macro Ctrl+X,E
F4 Next screen Ctrl+V
F5 Previous screen Esc,V
F6 Split window Ctrl+X,2
F7 One window Ctrl+X,1
F8 Scroll window up Ctrl+Z
F9 Scroll window down Esc,Z
F10 Save file and exit Ctrl+X,Ctrl+F
Help Insert line Ctrl+J
Enter (keypad) Insert line Ctrl+J

Commands Not in Menus

The following commands are only accessible through the keyboard.

Keys are bound when they can be used to perform a function. For example, any key or key sequence that can be used as a shortcut for a menu item is bound to that menu item.

Describe Key Esc,
Ctrl+D
Tells you if any functions are bound to a key or key sequence. At the prompt enter the specific key or key sequence.
Bind Key Esc,
Ctrl+B
Allows you to bind a key to a function. At the prompt, enter the key or key sequence.
Unbind Key Esc,
Ctrl+U
Allows you to return a bound key to an unbound state. At the prompt, enter the key or key sequence. Standard bound keys cannot be unbound.
Echo Esc,
Ctrl+E
Displays the string entered in the command line.
Move to Edge of Window Shift+Arrow Moves the cursor to the top, bottom, left, or right edge of the screen.
Delete the Next Character Ctrl+D Deletes the character at the current position. Same as pressing Del.
Delete the Previous Character Ctrl+H Deletes the character to the left of the current cursor position. Same as pressing Backspace.
Move to Next Line Ctrl+M Inserts a newline character after the current cursor position and moves the cursor to the start of the new line.
Move x number of Characters Ctrl+F,
Ctrl+B
Allows you to move the cursor forward or backward a specified number of spaces. Providing no value moves the cursor only one character.

Customizing MEmacs

MEmacs looks for an Emacs_pro file when it is opened to see if there are any command or local files that it should automatically execute. You can customize the Emacs_pro file by adding commands to it that you use often, command sequences, or text strings. If an Emacs_pro file does not already exist, you can create one.

To create a global file of commands, place the Emacs_pro file in the S: directory. Local files can be out in any directory. If that directory is the current directory when MEmacs is opened, the commands in that particular local file are executed.

When both local and global Emacs_pro files are present, the local file overrides the global file.

For example:

Set Case On
Set-Key F11 "Dear Sirs:"
Set-Key F12 "^S Workbench"
Set-Key F13 "^X^B"

makes the following assignments:

Shift+F1 Enter the text string "Dear Sirs:".
Shift+F2 Search forward for the next occurrence of the word Workbench. (The Set Case On commands make any text searches case-sensitive.)
Shift+F3 Display the list of buffers.

You must use Ctrl+Q to enter a Ctrl+key sequence. For example, to enter the ^S character shown in the example, press Ctrl+Q, Ctrl+S.

Quitting MEmacs

You can exit MEmacs by selecting the Quit menu item in the Project menu or by entering Ctrl+C. MEmacs lets you save any modified buffers or quit without saving.

EDIT

EDIT is a line editor designed for the automated editing of files, particularly binary files or files that are larger than available memory. You cannot create a new file with EDIT.

EDIT processes files line by line. As EDIT moves through the input, or source file, each line is passed after alteration to a sequential output file, the destination file.

EDIT processes the lines in files in a forward direction; however, you can move backward a limited number of lines. EDIT holds the lines in an output queue before writing them to the destination file. The size of this queue depends on the amount of memory available. You can increase the size of the queue with the OPT P and OPT W options.

The format for EDIT is the following:

EDIT [FROM] <filename> [[TO] <filename>] [WITH <filename>] [VER <filename>]
[OPT P <lines> | W <chars> | P<lines>W<chars>] [WIDTH <chars>] [PREVIOUS <lines>]

The FROM argument specifies the source file to be edited. You must specify a source file with EDIT, although the FROM keyword is optional.

The TO argument specifies the destination file to which EDIT sends its output, including editing changes. If you omit the TO argument, EDIT uses a temporary file. This temporary file is renamed with the name of the FROM file and overwrites the FROM file when editing is complete.

The WITH keyword specifies a file containing editing commands.

The VER keyword specifies the file to which EDIT sends error messages and line verifications. If the VER argument is not given, EDIT uses the screen.

Use OPT P <n> and OPT W <n> to specify the PREVIOUS and WIDTH options. However, do nit use the OPT keyword with PREVIOUS and WIDTH.

You can use the PREVIOUS and WIDTH options to increase or decrease the amount of available memory. The PREVIOUS option sets the number of previous lines available to EDIT to the integer <n>. The WIDTH option sets the maximum number of characters allowed on a line to <n>. EDIT multiples the number of previous lines by the maximum number of characters (PREVIOUS * WIDTH) to determine the available memory. The default values are PREVIOUS 40 WIDTH 120.

Starting EDIT

Start EDIT through a Shell using the following command:

1.< EDIT <filename>

Where <filename> is the name of an existing file to be edited.

EDIT Commands

The following list provides background information about EDIT commands:

Current line Refers to the line that EDIT is working on at any time. Every command entered refers to the current line, all text changes are made to the current line, and new lines are inserted before the current line.
Original lines The lines of the source file. Lines retain their original number until you renumber them with the REWIND or = commands.
Non-original lines Any lines that are inserted into the source file or original lines that are split. These are not assigned line numbers.
Line verification When using commands that change information in a line, EDIT displays the revised line after the command is executed.
Arguments Strings, qualified strings, numbers, and switch values used with EDIT commands.

Enter commands in one of the following three ways:

  • Enter the commands, then press Return
  • Enter the final command argument, then press Return
  • Enter a semicolon or closing parenthesis

The text conventions used in the command description are the following:

  • Command names are shown in upper case, although EDIT is not case-sensitive.
  • Angle brackets indicate that information must be substituted. For example, <string> indicates that the command takes a string argument.
  • An <n> represents a numeric argument.
  • Square brackets indicate that the argument is optional. For example, [<n>] indicates that the command can take an optional numeric argument.
  • Slashes are used as delimiters for strings; use one slash between two strings.
  • Periods are used as delimiters for file names (slashes cannot be used since they are used to separate strings).

Selecting the Current Line

The following commands let you move through the file and select the current line.

Move to a specific line number M <n> Specify a new current line by entering its line number, a period, and an asterisk as M's argument. Only original lines can be accessed by line number.
Move to next line in the source file N Move forward one line. Entering a number and N indicates the number of lines to move forard. When used as the last line of the source file, EDIT creates an extra line at the end of the file. If you are already on this extra line, using N causes an error message to be displayed.
Move to the previous line in the source file P Moves back one line. Entering P repeatedly moves more than one line. Entering a number + P indicates how many lines to move back. You can only move back to previous lines that have not yet been written to the destination file. The default is 40 lines, which can be changed with the PREVIOUS option.
Find F<string> Lets you select a current line by specifying some of its content.
Search Backward B,F<string> Looks backward starting from the current line through the source file for a line containing the specified string.

Editing the Current Line

The following commands add new material or replace material on the current line.

Insert <string2> after <string1> A <string1> <string2> Insert <string2> after the first occurrence of <string1>.
Insert <string2> before <string1> B <string2> <string1> Insert <string2> before the first occurrence of <string1>.
Exchange <string2> for <string1> E <string2> <string1> Replaces the first occurrence of <string1> with <string2>.

Inserting and Deleting Lines

The following commands insert new material (non-original lines) and delete lines from the source file. You can also insert complete files into the source file.

Insert one or more lines I [<n>] If given alone or with a line number, inserts text before the current line.

If given with an asterisk, the text is inserted at the end of the file.
Indicate the end of the insertion by pressing Return, Z, and Return.

Delete one or more lines D [<n>] Deletes the current line if entered with no arguments. Deletes a specific line if entered with a line number. Deletes a set of lines if entered with a range of line numbers; do not use punctuation between the numbers. Deletes everything from the current line through the end of the source file of entered with a period and an asterisk as arguments.
Delete all lines until the specified string is found D,F<string> Deletes successive lines from the source file until the line containing the matching string is found. If no argument is specified, it deletes all lines until it finds the last string specified.
Delete existing lines and replace with new text R [<n>] Lets you delete line and then insert new ones. Entering a line number following R indicates a specific line to replace.
Change the terminator Z <string> Tells EDIT that it has reached the end of any new text that is being inserted. Entering a string after Z changes it from the default.
Show current information about EDIT S,H,D Displays saved information values, such as the last string searched for, the last command entered, and the input terminator.
Turn trailing spaces on/off T,R,+|- Preserves any blanks that fall at the end of lines.

Editing Line Windows

You can define subsections of the line, called line windows, on which EDIT executes all subsequent commands. In the descriptions of EDIT qualifiers, the beginning of the line always indicates the beginning of the line window.

Whenever EDIT verifies a current line, it indicates the position of the line window by displaying a > character directly beneath the line. EDIT omits the pointer if the line window begins at the start of the line.

The following commands control the position of the character pointer:

> Moves the pointer one character to the right.
< Moves the pointer one character to the left.
PR Resets the pointer to the start of the line.
PA <string> Moves the pointer to the first character after the specified string.
<string> Moves the pointer to the first character before the specified string.

The following commands change the character at the current pointer, then move the pointer.

$ Makes the character at the pointer lower case, then moves the pointer one character to the right.
% Makes the character at the pointer upper case, then moves the pointer one character to the right.
_ The _ (underscore) command deletes the character at the pointer, turning it into a space, then moves the pointer one character to the right.
# Deletes the character at the pointer, then moves the rest of the line one character to the left. To delete several characters, specify a number before the #. For example, 5# deletes the next five characters in the window.

A combination of these commands can be used to edit a line character by character.

The following commands insert and exchange text on the current line, similar to the A, B, and E commands; however, the character pointer is moved on completion.

Insert <string2> after <string1> A,P <string1> <string2> Inserts <string2> after the first occurrence of <string1>. The pointer is then positioned after <string2>.
Insert <string2> before <string1> B,P <string1> <string2> Inserts <string2> before the first occurrence of <string1>. The pointer is then positioned after <string2>.
Exchange <string1> with <string2> E,P, <string1> <string2> Replaces the first occurrence of <string1> with <string2>. The pointer is then positioned after <string2>.
Delete Till After D,T,A <string> Deletes all text from the beginning of the line or the character pointer to the end of the specified string.
Delete Till Before D,T,B <string> Deletes all text from the beginning of the line or the character pointer; stops before the specified string.
Delete From After D,F,A <string> Deletes all text starting after a specified string to the end of the line.
Delete From Before D,F,B <string> Deletes all text starting with the specified string to the end of the line.

Splitting and Joining Lines

These commands split a line into more than one line and join together two or more successive lines.

Split line before <string> S,B <string> Splits the current line before the specified string. The first part of the line is sent to the output queue; the second part is made into a new non-original current line. Qualifiers can be used to restrict the context of the string.
Split line after <string> S,A <string> Splits the current line after the specified string. The first part of the line is sent to the output queue; the remainder of the line becomes the new current line. Qualifiers can be used to restrict the context of the string.
Join two lines C,L [<string>] Joins the current line with the next line of the source file. The string argument is optional; however, if a string is specified it is added to the end of the current line and that whole line is joined with the next line in the source file.

Renumbering Lines

These commands renumber the source file's lines to include non-original lines and to update a file that has been edited.

Renumber source lines = <n> Sets the current line number to <n>. All subsequent original and non-original lines below <n> are renumbered you move to them.
Return to the beginning source file REWIND Moves back through the source file to make line 1 the current line. EDIT scans the rest of the source file and writes the lines to the destination file. This file is closed and reopened as a new source file. Non-original lines are now recognized as original lines. Can be entered as REWI.

Verifying Lines

These commands describe different ways of verifying lines.

Turn Verification on/off V + | - Turns line verification on or off. If off, the lines are not displayed on the screen. To turn off, enter V -. To turn on, enter V +.
Verify the current line ? Verifies the current line by displaying the line number and the contents of the line.
Verify the current line with character indicators ! Produces two lines of verification. In the first line all non-graphic characters are replaced with the first character of their hexadecimal value In the second line, a minus sign is displayed under all positions corresponding to upper case letters and the second hexadecimal digit corresponds to non-graphic characters. All other positions contain spaces. In binary files, non-graphic characters are represented with question marks (??).

Inspecting the Source File

These commands advance through the source file, sending the lines it passes to the verification file, as well as to the normal output. They are known as Type commands because they display lines on the screen.

Type <n> lines to the screen T <n> Types the specified number of lines to the screen. The first line typed is the current line. Omitting the <n> continues typing to the end of the source file. Interrupt the command with Ctrl+C.
Type the lines in the output queue T,P Displays the lines currently held in the output queue.
Type until EDIT has replaced all the lines in the output queue T,N Types from the current line forward until all the lines in the output queue are replaced. The previous contents are sent to the destination file.
Type with line numbers T,L <n> Similar to the T command. Types a specified number of lines, displaying the line numbers. EDIT displays + + + + for inserted or split lines since they do not have line numbers.

Making Global Changes

These commands start and stop global changes. Global changes take place automatically as EDIT scans the source file in forward direction. These commands automatically apply an A, B, or E command, as appropriate, to any occurrence of <string1> in a new current line. They also apply to the current line that is in effect when the command is given.

GA [qualifier] <string1> <string2>
GB [qualifier] <string1> <string2>
GE [qualifier] <string1> <string2>

For example, if you want to change DF0: to DF2: throughout an entire file, enter:

GE /DF0:/DF2:/
Cancel a global command CG [<id number>] Cancels a global command. The identification number set with a GA, GB, or GE command is output to the verification file or the serene if EDIT is interactive. If no argument is specified, all global operations are cancelled. To cancel a specific operation, enter the identification number of the CG command.
Suspend a global command SG [<id number>] Suspends a global command. All global operations are suspended if no argument is given. Enter the identification number to suspend a specific operation.
Enable a global command EG [<id number>] Resumes global operation that had been suspended with the SG command. Unless a specific identification number is provided, all global commands are resumed.
Show global commands SHG Displays the current global commands and their identification numbers. Also provides the number of times each global string was matched.

Changing Command, Input, and Output Files

These commands change the files set up when you started EDIT from the Shell. These files are:

  • the command file - started with the WITH option.
  • the input file - the source file specified with FROM.
  • the output file - the destination file specified with TO.
Changing the Command File C <filename> Reads EDIT commands from a specified file. Delimit the file using a character other than a slash (/) since AmigaDOS uses these characters to separate file names. When all commands in the specified file are executed, the file is closed. You can then enter the commands through the keyboard.
Changing the Input File FROM <filename> Reads lines from another source file. EDIT does not close the original source file. Reselect the source file by entering the FROM command without an argument. For example of the FROM command, see page 4-54.
Closing a File CF <filename> Closes the destination file that was originally specified with the TO command. You can then open that file for input. CF can also close a new input file that is open. For examples of the CF command, see page 4-54.
Changing the Output File TO <filename> Specifies a different file as the destination file. The TO command writes the existing queue of output lines to the new TO file. The new TO file is used until another file is specified. Reselect the original destination file by using the TO command with no argument. The alternate output file remains open, but unused. For examples of the TO command, see page 4-54.
Stop executing the command file Q Stops EDIT from executing the current command file specified with the WITH keyword or with the C command. EDIT reverts to any previous command file. Using Q at the outermost level is equivalent to using the W command.

The FROM, CF, and TO commands are used as follows:

Command Action
M10 Pass lines 1-9 in the original source file to the output queue.
FROM .XYZ. Select the XYZ file for new input; line 10 of the original source file remains current.
M6 Pass line 10 from the original file, then pass lines 1-5 from the XYZ file to the output queue. Line 6 of XYZ is the new current line.
FROM Reselect the original source file.
M14 Pass line 6 from XYZ, then lines 11-13 from the original source file to the output queue. Line 14 of the source file is the new current line.
FROM .XYZ. Reselect file XYZ. Line 14 of the source file is still the current line.
M* Pass line 14 of the source file and all remaining lines of file XYZ to the output queue. An extra line is added to the end of file XYZ. That line is the new current line.
FROM Reselect the original source file. The extra line added to file XYZ is still the current line.
CF .XYZ. Close file XYZ.
M* Pass the remaining lines of the source file (lines 15 to the end of the file) to the output queue.
M11 Pass lines 1-10 of the source file to the original destination file.
TO .XYZ. Make XYZ the new output file.
M21 Pass lines 11-20 to file XYZ.
TO M31 Make the original destination file current, and pass lines 21 to 30 to it.
TO .XYZ. Make XYZ the current output file.
M41 Pass lines 31 to 40 to XYZ.
TO Make the original destination file current.
TO .XYZ. Send the output queue to file XYZ.
1000N Advance through the next 1000 lines of the source file.
TO Select the original destination file.
CF .XYZ. Close the XYZ file.
I2000 .XYZ. Insert the 1000 lines from the source file that were sent to file XYZ back into the source file above line 2000.

Ending EDIT

These commands exit EDIT.

Exit, saving changes W Exits EDIT, saving all changes to the destination file specified by TO. EDIT exits after reaching the end of the source, closing all the files, and relinquishing memory. If you started EDIT without specifying a destination file, it renames the temporary destination with the same name as the original source file, which is renamed. T/Edit-backup. This backup is only available until the next time you run EDIT.
Exit, without saving changes STOP Stops EDIT immediately without saving any changes to the source file. Prevents EDIT from overwriting to original source file, ensuring that no changes are made to the original input information.