TECO TECO is a character oriented text editor available by typing TECO filespec edit file to a new version, or TECO outfile=infile edit infile to outfile, or TECO/VT filespec edit file to a new version with screen editor, or TECO/VT outfile=infile edit infile to outfile in screen editor. The following subtopics are selections from the TECO manual. For help on a given subtopic, type: HELP TECO VTEDIT *** IMPORTANT *** HELP TECO CHARACTERS HELP TECO FILESELECTION HELP TECO MODIFICATION HELP TECO SYNTAX HELP TECO INPUT/OUTPUT HELP TECO SEARCH HELP TECO EXITING HELP TECO ERRORS HELP TECO POINTER HELP TECO INDEX HELP TECO DATA HELP TECO TYPOUT 2 VTEDIT VTEDIT is the screen editing version of TECO. It is initiated by typing TECO/VT The full document describing usage of VTEDIT may be obtained by either of the following commands: To view the document on your terminal: HELP TECO VTEDIT DOCUMENT To print the document on the line printer: PRINT LB:[1,2]TECODOC.HLP 3 DOCUMENT @TECODOC 2 INDEX Characters What notation is used to represent control characters in the manual Syntax General form of TECO commands (e.g., how to specify a count for characters or lines to move). Errors Form of TECO error messages Exiting How to exit from TECO Data TECO data structures; how TECO treats text it is editing. File Select How to select or change the input and/or output files you are editing. Input/Output How to read input files or write output files (commands to actually fill memory from a file or write out your edited text to your output file). Pointer How to move the TECO editing pointer by characters or lines Typout How to get TECO to type out some or all of the text in memory Modification How to insert or delete text in your file. Search How to locate the occurrence of a character string 2 CHARACTERS The following notation is used in this manual to represent special characters: Notation ASCII code (octal) Name 0 Null 10 Backspace 11 Tab 12 Line Feed 13 Vertical Tab 14 Form Feed 15 Carriage Return or $ 33 Escape or Altmode - Control-x 40 Space 177 Delete or Rubout Control characters, , are produced by striking the CONTROL key and a character key simultaneously. 2 SYNTAX TECO will respond by printing an asterisk at the left margin to indicate that it is ready to accept user commands. At this point, you may type one or more commands. A TECO command consists of one or two characters which cause a specific operation to be performed. Some TECO commands may be preceded or followed by arguments. Arguments may be either numeric or textual. A numeric argument is simply an integer value which can be used to indicate, for example, the number of times a command should be executed. A text argument is a string of ASCII characters which might be, for example, words of text or a file specification. If a command requires a numeric argument, the numeric argument always precedes the command. If a command requires a text argument, the text argument always follows the command. All text arguments are terminated by a special character (usually an ESCAPE) which indicates to TECO that the next character typed will be the first character of a new command. TECO accumulates commands as they are typed in a command string, and executes commands upon receipt of two consecutive ESCAPE characters. The ESCAPE is a non-printing character which may be labelled ESC, ALT, or PREFIX on your keyboard. TECO echoes a dollar sign ($) whenever an ESCAPE is typed. The dollar sign character is used in examples throughout this manual to represent ESCAPE. Note that the carriage return character has no special significance to TECO. Only the double ESCAPE forces execution of the command string. TECO executes command strings from left to right until either all commands have been executed or a command error is recognized. It then prints an asterisk to signal that additional commands may be entered. 2 ERRORS If TECO encounters an erroneous command, it prints an error message and ignores the erroneous command as well as all commands which follow it. All error messages are of the form: ?XXX Message where XXX is an error code and the message is a description of the error. Some error messages mention the specific character or string of characters in error. In these error messages, TECO represents the non-printing special characters as follows: Character Form Displayed <^x> Every error message is followed by an asterisk at the left margin, indicating that TECO is ready to accept additional commands. If you type a single question mark character after a TECO-generated error message, TECO will print the erroneous command string up to and including the character which caused the error message. This helps you to find errors in long command strings and to determine how much of a command string was executed before the error was encountered. You can correct typing errors by hitting the DELETE key, which may be labeled DEL or RUBOUT on your keyboard. Each depression of the DELETE key deletes one character and echoes it on your terminal, beginning with the last character typed. If your terminal is a CRT, TECO will actually erase the deleted character from the screen. You can delete an entire command string this way, if necessary. To delete an entire line of commands, enter the character , typed by holding down the CONTROL key while depressing the "U" key. 2 EXITING When you are done editing, use the EX command to exit TECO, fol- lowed by 2 ESC characters. If there is no output file, you may need to use the command HKEX$$ to exit. ("$$" means 2 ESC chars.) 2 DATA TECO considers any string of ASCII codes to be text. Text is broken down into units of characters, lines, and pages. A character is one ASCII code. A line of text is a string of ASCII codes including one line terminator (usually a line feed) as the last character on the line. A page of text is a string of ASCII codes including one form feed character as the last character on the page. TECO maintains a text buffer in which text is stored. The buffer usually contains one page of text, but the terminating form feed character never appears in the buffer. TECO also maintains a text buffer pointer. The pointer is a movable position indicator which is never located directly on a character, but is always between characters: between two characters in the buffer, before the first character in the buffer, or after the last character in the buffer. Line feed and form feed characters are inserted automatically by TECO. A line feed is automatically appended to every carriage return typed to TECO and a form feed is appended to the contents of the buffer by certain output commands. Additional line feed and form feed characters may be entered into the buffer as text. If a form feed character is entered into the buffer, it will cause a page break upon output; text following the form feed will begin a new page. Finally, TECO maintains an input file and an output file, both of which are selected by the user through file specification commands. The input file may be on any device from which text may be accepted. The output file may be on any device on which edited text may be written. TECO functions as a "pipeline" editor. Text is read from the input file into the text buffer, and is written from the buffer onto the output file. Once text has been written to the output file, it cannot be accessed again without closing the output file and reopening it as an input file. 2 FILESELECTION Input and output files may be specified to TECO in several ways. The following sections present first a simple method for specifying files, and then more sophisticated commands that permit flexible file selection. NOTE All of the following file selection commands are shown with a general argument of "filespec". The actual contents of this filespec argument are operating system dependent. See the operating characteristics appendices. Examples include a mixture of file specifications from various operating systems. 1.3.1 Simplified File Selection For most simple applications, you can use special operating system commands to specify the name of the file you wish to edit at the same time that you start up TECO. To create a new file: MAKE filespec This command starts up TECO and creates the specified file for output. To edit an existing file: TECO filespec This command starts up TECO and opens the specified file for editing while preserving the original file (as a backup file). It also automatically brings the first page of the file into the text buffer. These functions simulate the EB command described in Chapter 5. If any of the above commands do not seem to work on your operating system, consult the appropriate appendix for information about how to install TECO and its associated operating system commands. Input File Specification (ER command) TECO will accept input text from any input device in the operating system. The input device may be specified by means of an ER command terminated by an ESCAPE. The ER command causes TECO to open the specified file and print an error message if the file is not found. This command does not cause any portion of the file to be read into the text buffer, however. The following examples illustrate use of the ER command. COMMAND FUNCTION ERfilespec$ General form of the ER command where "filespec" is the designation of the input file. The command is terminated by an ESCAPE, which echoes as a dollar sign. ERPR:$ Prepare to read an input file from the paper tape reader. ERPROG.MAC$ Prepare to read input file PROG.MAC from the system's default device. ERDX1:PROG.FOR$ Prepare to read input file PROG.FOR from DX1:. TECO will only keep one input and one output file open and selected at a time. The current input file may be changed by simply using the ER command to specify a new file. It is not always necessary to specify an input file. If you want to create a file without using any previously edited text as input, you may type commands to insert the necessary text directly into the text buffer from the keyboard and, at the end of each page, write the contents of the buffer onto an output file. Since all input is supplied from the keyboard, no input file is necessary. Output File Specification (EW command) TECO will write output text onto any output device in the operating system. The output file may be specified by means of an EW command terminated by an ESCAPE. If the output device is a file-structured device (for example, a disk), the file name and any extension must be supplied. If a file name is specified but no device is explicitly defined, the system's default device is assumed. The following examples illustrate use of the EW command. COMMAND FUNCTION EWfilespec$ General form of the EW command where "filespec" is the designation of the output file. The command is terminated by an ESCAPE, which echoes as a dollar sign. EWSYS:TEXT.LST$ Prepare to write output file TEXT.LST on SYS:. EWPROG$ Prepare to write output file PROG on the system's default device. ERDX1:INPUT.MAC$EWOUTPUT.MAC$$ Open an input file INPUT.MAC to be found on DX1: and open an output file named OUTPUT.MAC. The double ESCAPE ($$) terminates the command string and causes the string to be executed. Note that the ESCAPE which terminates the EW command may be one of the two ESCAPEs which terminates the command string. You do not need to specify an output file if you only want to examine an input file, without making permanent changes or corrections. In this case, the contents of the input file may be read into the text buffer page by page and examined at the terminal. Since all output is printed on the user terminal, no output file is needed. Closing Files (EX command) When you are finished editing a file, use the EX command to close out the file and exit from TECO. The current contents of the text buffer and any portion of the input file that has not been read yet are copied to the output file before TECO exits. The EX command takes no arguments. COMMAND FUNCTION EX Write the text buffer to the current output file, move the remainder of the current input file to the current output file, close the output file, then return to the operating system. ERFILE.MAC$EWCOPY.MAC$EX$$ Open an input file FILE.MAC and open an output file named COPY.MAC, then copy all the text in the input file to the output file, close the output file, and exit from TECO. 2 INPUT/OUTPUT TECO INPUT AND OUTPUT COMMANDS The following commands permit pages of text to be read into the TECO text buffer from an input file or written from the buffer onto an output file. Once a page of text has been written onto the output file, it cannot be recalled into the text buffer unless the output file is closed and reopened as an input file. COMMAND FUNCTION Y Clear the text buffer, then read the next page of the input file into the buffer. Since the Y command causes the contents of the text buffer to be lost, it is not permitted if an output file is open and there is text in the buffer. P Write the contents of the text buffer onto the next page of the output file, then clear the buffer and read the next page of the input file into the buffer. nP Execute the P command n times, where n must be a positive (non-zero) integer. If n is not specified, a value of 1 is assumed. After each Y, P, or nP command, TECO positions the pointer before the first character in the buffer. 2 POINTER TECO POINTER POSITIONING COMMANDS The buffer pointer provides the means of specifying the location within a block of text at which insertions, deletions or corrections are to be made. The following commands permit the buffer pointer to be moved to a position between any two adjacent characters in the buffer. COMMAND FUNCTION J Move the pointer to the beginning of the buffer. L Move the pointer forward to a position between the next line feed and the first character of the next line. That is, advance the pointer to the beginning of the next line. nL Execute the L command n times, where n is a signed integer. A positive value of n moves the pointer to the beginning of the nth line following the current pointer position. A negative value moves the pointer backward n lines and positions it at the beginnning of the nth line preceding the current position. If n is zero, the pointer is moved to the beginning of the line on which it is currently positioned. C Advance the pointer forward across one character. nC Execute the C command n times, where n is a signed integer. A positive value of n moves the pointer forward across n characters. A negative value of n moves the pointer backward across n characters. If n is zero, the pointer position is not changed. Remember that there are two characters, and , at the end of each line in the buffer. These commands may be used to move the buffer pointer across any number of lines or characters in either direction; however, they will not move the pointer across a page boundary. If a C command attempts to move the pointer backward beyond the beginning of the buffer or forward past the end of the buffer, an error message is printed and the command is ignored. If an L command attempts to exceed the page boundaries in this manner, the pointer is positioned at the boundary which would have been exceeded. Thus, in a page of 2000 lines, the command "-4000L" would position the pointer before the first character in the buffer. The command "4000L" would position the pointer after the last character in the buffer. No error message is printed in either case. 2 TYPOUT TECO TYPE OUT COMMANDS The following commands permit sections of the text in the buffer to be printed out on your terminal for examination. These commands do not move the buffer pointer. COMMAND FUNCTION T Type the contents of the text buffer from the current position of the pointer through and including the next line feed character. nT Type n lines, where n is a signed integer. A positive value of n causes the n lines following the pointer to be typed. A negative value of n causes the n lines preceding the pointer to be typed. If n is zero, the contents of the buffer from the beginning of the line on which the pointer is located up to the pointer is typed. This is useful for verifying the location of the buffer pointer. HT Type the entire contents of the text buffer. V Type the current line. Equivalent to the sequence "0TT". TECO Immediate Action Commands In addition, there are two special type out commands available as a convenience. They are abbreviations for two frequently used commands. These commands consist of a single character and must be the very first character typed after TECO prints its prompting asterisk. They take effect immediately; there is no need to follow these commands by an ESCAPE character. For this reason, these commands are known as immediate action commands. COMMAND FUNCTION Immediately execute the LT command. This command is issued by typing the line feed key as the first keystroke after TECO's prompt. It causes TECO to move the pointer ahead one line and then type out the new line. Immediately execute the -LT command. This command is issued by typing the backspace key as the first keystroke after TECO's prompt. It causes TECO to move the pointer back one line and then type the line just moved over on the terminal. On terminals without a backspace key, typing has the same effect. These commands are useful for "walking through" a file, examining and/or modifying lines one at a time. 2 MODIFICATION TECO TEXT MODIFICATION COMMANDS You can insert or delete text from the buffer using the following commands: COMMAND FUNCTION Itext$ Where "text" is a string of ASCII characters terminated by an ESCAPE (which echoes as a dollar sign). The specified text is inserted into the buffer at the current position of the pointer. The pointer is positioned immediately after the last character of the insertion. K Delete the contents of the text buffer from the current position of the pointer up to and including the next line feed character. nK Execute the K command n times, where n is a signed integer. A positive value of n causes the n lines following the pointer to be deleted. A negative value of n causes the n lines preceding the pointer to be deleted. If n is zero, the contents of the buffer from the beginning of the line on which the pointer is located up to the pointer is deleted. HK Delete the entire contents of the text buffer. D Delete the character following the buffer pointer. nD Execute the D command n times, where n is a signed integer. A positive value of n causes the n characters following the pointer to be deleted. A negative value of n causes the n characters preceding the pointer to be deleted. If n is zero, the command is ignored. Like the L and C commands, the K and D commands may not execute across page boundaries. If a K command attempts to delete text up to and across the beginning or end of the buffer, text will be deleted only up to the buffer boundary and the pointer will be positioned at the boundary. No error message is printed. A D command attempting to delete text past the end or beginning of the text buffer will produce an error message and the command will be ignored. 2 SEARCH TECO SEARCH COMMANDS The following commands may be used to search the input file for a specified string of characters. COMMAND FUNCTION Stext$ Where "text" is a string of ASCII characters terminated by an ESCAPE (which echoes as a dollar sign). This command searches the text buffer for the next occurrence of the specified character string following the current pointer position. If the string is found, the pointer is positioned after the last character on the string. If it is not found, the pointer is positioned immediately before the first character in the buffer and an error message is printed. Ntext$ Performs the same function as the S command except that the search is continued across page boundaries, if necessary, until the character string is found or the end of the input file is reached. If the end of the input file is reached, an error message is printed. You must then close the output file and reopen it as an input file before you can edit the file further. Both the S command and the N command begin searching for the specified character string at the current position of the pointer. Therefore, neither command will locate any occurrence of the character string which precedes the current pointer position, nor will it locate any character string which is split across a page boundary. Both commands execute the search by attempting to match the command argument, character for character, with some portion of the buffer contents. If an N command reaches the end of the buffer without finding a match for its argument, it writes the contents of the buffer onto the output file, clears the buffer, reads the next page of the input file into the buffer, and continues the search.