Using the ED Editor
 

 

A text editor or word processing program is necessary for creating or editing text files and script files. Amiga Workbench software comes with the ED text editor, which has the basic functionality of a word processor. However, ED does not support style-formatting options, such as italics, page numbering, or different fonts. This section describes how to use ED, including the following:

 

 

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.

 

 

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.

 

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 spec>) [TABS <n>] [WIDTH | COLS <n>] [HEIGHT | ftOWS <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
  • increases 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 WINDOW argument specifies the console type, such as RAW:O/0/640/256/EdWindow or CONSOLE:.

    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.

     

    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:

    1. By choosing the command's menu item.
    2. 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. ED 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:

    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.

    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 to 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 sile or sottom of sile 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).

    Shift+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 Lonq 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 typeover 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+0
    If the cursor is over a space, all spaces up to the next character are deleted. If the cursor is over acharacter, all characters up to the next space are deleted.

    Ctrl+Y
    Deletes ail 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:

     

    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.

     

    Using String Delimiters

    In some cases, commands require arguments, such as a number or a text string. A string argument for an ED command must be enclosed in a pair of identical delimiter characters. In unambiguous situations you can omit the trailin 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. If a command needs two string arguments, you can enter them together, inserting a third delimiter character. For example,

    "stringl"string2".

     

    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 ofcommand mefu assignments: default and expanded. The default menu assignments, as illustrated in Figure 12-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, or define preprogrammed function key assignments with the Set FN Key menu item.

     

    Enabling Expanded Menus

    The expanded command menu assignments, 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.

    Rather than 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,0verwriting the existing text in the file. Use Save As to save to a 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 displays 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. Identifies 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.

    Start Block
    Esc,B,S
    End Block
    Esc,B,E

    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.
    Shitt+up arrow

    Bottom
    Esc,B
    Bottom of the file; last line of the file is brought to the bottom of the window.
    Shitt+dow
    n arrow

    Next Page
    Esc,P,D
    Go to next page.
    Ctrl+D

    Previous Page
    Esc,P,U
    Go to previous page.
    Ctrl+U

     

    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.

     

    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 senrch fniled 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, F

    Finds the next occurrence of the specified Find Next 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 UC 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 12-14 for instructions for defining function keys and an example of the Set FN Key command.

     

    Show FN
    Esc,D, F

    Displays the setting for the function key specified by <key>. Enter a space and a key slot number for <key>.
    Key <key>

    Reset Keys
    Esc,R,K
    Resets the key definitions to the default.

    Right Margin
    Esc, R,K
    Sets the right margin. To specify the right margin, use the SR command followed by a number indicating the column position.

    Left Margin
    Esc,S,L
    Sets the left margin. To specify 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 text. 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 key slots ranging from 1 to 57. Any slot number can be redefined and any numbers within the range that do not appear here 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 Fl 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 SequenceFunction
    1-10F1 through F10Not defined
    11-20Shift+F1 to shift+F10Not defined
    21Shift+left arrowMove to beginning of line
    22Shift+right arrowMove to end of line
    23Shift+up arrowMove to top of document
    24Shift+down arrowMove to bottom of document
    25DelDelete character at cursor
    26Not definedNot defined
    27Ctrl+AInsert line
    28Ctrl+BDelete line
    29Ctrl+CNot defined
    30Ctrl+DMove down 12 lines
    31Ctrl+EMove to top or bottom of screen
    32Ctrl+FChange case
    33Ctrl+GRepeat last extended command line
    34Ctrl+HDelete character left of cursor
    35Ctrl+IMove cursor to next tab position
    36Ctrl+JNot defined
    37Ctrl+KNot defined
    38 Ctrl+ Not Defined
    39 Ctrl+ Return
    40 Ctrl+ Not Defined
    41 Ctrl+ Delete word or spaces
    42 Ctrl+ Not Defined
    43 Ctrl+ Not Defined
    44 Ctrl+ Move to end of previous word
    45 Ctrl+ Not Defined
    46 Ctrl+ Move to start of next word
    47 Ctrl+ Move up 12 lines
    48 Ctrl+ Redisplay window
    49 Ctrl+ Not Defined
    50Ctrl+Not Defined
    51Ctrl+Delete to end of line
    52Ctrl+Not Defined
    53Ctrl+ESC ( enter extended command mode )
    54Not DefinedNot Defined
    55Ctrl+Move to end or start of line, depending on cursor position
    56Not DefinedNot Defined
    57Not DefinedNot Defined

     

    Command Menu

    The following commands are for non-text oriented functions:

    Extended Command
    Esc,C,M

    Enters extended command mode; equivalent to pressing Ctrl+[ or Esc.

    Repeat Last
    Esc, R,E/Ctrl+G

    Attempts to repeats the last command.

    Run File
    Esc, R,F

    Loads and executes a command file of extended mode commands.

     

    Arexx
    Esc,R,X

    Runs the specified ARexx program. Command...

    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 Esc,
    E,X

    Extends the margins for the current line.

    Margins Once you enter the EX command, ED ignores the right margin on the current line.

    Status Line
    Esc,S,M

    Prints a given string on the status line.

    Message

    Exit with Esc,X,Q Exits ED unless changes were made to the Ouery file. If changes have been made, the message File hns been chnnged-type Y to snve 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,l

    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 <
    Return>

    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/Ctrl+B

    Deletes the current line.

    Delete Character
    Esc,D,C/Del

    Deletes the character under the cursor.

    Delete Left
    Esc,D,L/Backspace

    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 letters.

    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 and 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 with the WITH argument. To execute the file from within ED, use the Run File (Esc,R,F) extended command. 

    Set Menu Item
    Esc,S,l

    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 page 12-20 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 12-21 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> /stringl/string2/

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

     

    Type FunctionString Input
    0End of MenusNo arguments
    1Menu HeadingStringl = heading name
    2Menu ItemStringl = item name
    String2 = command string
    3 Submenu HeadingStringl = heading name
    String2 = command string No arguments
    4Separator 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

     

    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 fle 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. If you wish to print part of a file, mark that part as a block and create a separate file to print using the Write Block command.

     

    Quitting ED

     

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

     Press Esc,X.
    This method exits ED and saves the current file to a designated file name that was specified when ED was opened. Press Esc,X,Q or click on the ED window's close gadget. This method exits ED if no changes were made td the file. If changes were made to the file, ED lets you save the changes or exit without saving.

    Press 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.