Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site vax135.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!vax135!cjp From: cjp@vax135.UUCP (Charles Poirier) Newsgroups: net.micro.amiga Subject: ED editor manual (long) Message-ID: <1299@vax135.UUCP> Date: Tue, 11-Feb-86 21:18:11 EST Article-I.D.: vax135.1299 Posted: Tue Feb 11 21:18:11 1986 Date-Received: Wed, 12-Feb-86 21:42:13 EST Organization: AT&T Bell Labs, Holmdel, NJ Lines: 267 I received the following information on how to use the ED editor. This comes from Robert A. Peck at Commodore-Amiga, who says he is writing this for inclusion in a book, hence please treat it as Copyrighted material. I'm sure some of you can use this. Charles Poirier From: amiga!robp (Robert A. Peck) APPENDIX A - THE ED EDITOR The ED program is a simple program text editor that you can use to create source files for your C compiler or for other purposes. If you start ED without specifying a file name or specifying a new file name, as ED starts, it presents you with a blank screen on which you can type lines of text. After you have completed typing those lines, you can save this text to a file for further use. If you start ED specifying a file name that already exists, you can use ED to edit that file. ED is basically a line editor rather than a word processor. That is, as you use ED, keep in mind that although ED presents you with a full screen of text to work with, ED treats each line as an individual entity. For example, a block of text consists of one or more lines. A text block mark cannot begin or end in the middle of a line. Likewise, when you move a block or copy a block of text, ED inserts the block in between the line in which the cursor currently resides and the line immediately above it. If you are unfamiliar with using a text editor to create a program, this section will guide you through creating a short program. If you are already using a text editor of some kind, you can ignore this appendix entirely. STARTING ED To start ED, make sure your Workbench or CLI diskette is in the internal drive. This disk must be write-enabled to allow the ED program to create a workfile in the SYS:T directory. From a CLI window, type ED hello.c A new window opens up and ED says: Creating a new file Your cursor is at the top of the window waiting for you to do something. As you gain experience with ED, you may tend to use more of its commands. However, a beginning user need only remember a few basic rules and commands in order to effectively use ED. 1. Remember that you are always in insert mode... Wherever the cursor is located, if you type a legal (non-command) character, it will insert that character at the cursor position and push everything else to the right if necessary. A RETURN key typed in the middle of a line splits the line. 2. The cursor keys work as expected. You can move through the file exclusively with the cursor keys if you wish. 3. The backspace key deletes the character to the immediate left of the cursor. 4. The ESC key is used for extended commands. If you press the ESC key, the cursor temporarily moves down to the status line at the bottom of the screen and waits for you to complete the extended command. The commands most often needed are: ESC sa - save your file and continue the ED session ESC q - exit the program without saving any further changes ESC x - exit the program after saving the current file in memory. Equivalent to save, then quit. It seems to be traditional that any textbook that shows either C or Pascal programming must begin, somehow, with the programming example that prints "Hello, world" to the console. Rather than break tradition, here is the complete sequence you would need to perform to create this program. Start ED as described above. You are creating a file named hello.c. Type the following lines exactly as shown, pressing the RETURN key as you reach the end of each line: main() { printf("\nHello, world\n"); } Then type: ESC x Now your program is saved so that it can be used later by the compiler. Other commands that ED can perform are summarized in the table A-1. Table A-1: ED Command Quick Reference In the table, the notation "^" indicates a "control" command. This means that you must hold down the CTRL key then press the specified command letter to execute a particular command. Cursor Movement: Arrow keys - move cursor in expected direction ^I - (TAB key) - move cursor forward to next tab stop ^R - move to end of previous word ^T - move to start of next word ^D - scroll text down ^U - scroll text up ^E - cursor to top or bottom of screen ^] - cursor to start or end of line ^M - same effect as RETURN key. That is, move cursor down one line and to left margin. ESC B - move to bottom of file ESC T - move to start of file ESC N - move to start of next line ESC P - move to start of previous line ESC CE - move to end of current line ESC CB - move to start of current line ESC M - move cursor to a specific line number within the file. Insert and Delete Functions: ^A - Insert a line AFTER the current line ^B - Delete the line in which the cursor is located ^H - (BACKSPACE) Delete the character to the left of the cursor. Move everything back one space. DEL - Delete character on which the cursor is sitting. ^O - If sitting on a space character, delete all spaces up to the next word on the line. If sitting on a non-space character, delete this and all characters to its right until the next space character is encountered. ^Y - Delete to the end of the line, including the character on which the cursor is resting. ESC A // - insert this string of characters as a line preceding the current line. ESC I // - insert this string of characters as a line following the current line. ESC D - delete the current line ESC DC - delete the character at the cursor ESC IF !! Insert file by this name at the current cursor position. ESC J - Combine this line and the next line as a single line (Join with the next line). ESC S - Split the current line at the cursor. Take the character at the cursor position and force it to become the first character on the following line. Editor Control Commands ESC LC - treat upper and lower case characters as different when performing searches. ESC SL - set the lefthand margin at column number specified. Default is 1. ESC SR - set the righthand margin at column numbers specified. Default is 80. Maximum is 255, since this is the maximum line length the ED program (and AmigaDOS) allows. ESC ST - set the tab distance to this number. How far apart should the standard tab stops be positioned. ESC SH - show the status of the editor. ESC V - redraw the screen. ESC EX - extend right margin (same as margin-release if you are using a typewriter). String Find and Replace ESC F // - search forward for the next occurence of the specified string of characters. ESC BF // - backward search for an occurence of the specified string of characters. ESC E/// - locate next occurence (forware search) of the specified old string and replace it with the new string. Do not verify, just replace without asking. ESC EQ/// - locate next occurence (forware search) of the specified old string and ask for verification.... is it ok to replace this particular occurence or not? Block Operations ESC BS - mark this line as the beginning of a block ESC BE - mark this line as the end of a block ESC DB - delete this entire block ESC IB - copy the marked block to the current cursor location. ESC SB - show the top line of the marked block as the top line of the screen. (Lets you quickly move to a marked position within the file). ESC WB !! - write the marked block out to a specified file. If the pathname is not simply to the current directory, you can specify the complete path name, including slashes, if exclamation points are used to delimit the pathname. Save and Read Operations ESC SA - save the file to the current file name and continue editing. ESC Q - quit without saving any changes made since most recent save if any. ED asks you to verify that it is ok to quit. ESC X - exit program, saving the changes to the current file name. Both ESC SA and ESC X accept an optional file name that is used in place of the filename used to open the file. This takes the form: ESC X !! or ESC SA !! so that you could, if you wish, save intermediate forms of the editing you are performing. Multiple Commands On A Line Once you have pressed ESC, the command line can contain multiple commands, separated by a semicolon. Example: F /a certain phrase/ ; E/oldword/newword/ searches for the string "a certain phrase", then following that phrase, searches for the next occurence of "oldword" and substitutes "newword" for it. Repeating Commands You specify how many times a command (or a command line) should be repeated by placing a number ahead of the command segment to be repeated. In place of the number of repeats, you can specify "RP", that says keep doing the same thing until you find an error of some kind.