.TH "QED" 1 . \" /*% nroff -man % .if t .ds q \(aa .if n .ds q ' .SH NAME qed \- multi-file text editor .SH SYNOPSIS .B qed [ .B \- ] [ .B \-i ] [ .B \-q ] [ .B \-e ] [ .B \-x startupfile ] [ filename1 filename2 ... ] .SH DESCRIPTION \fIQed\fP is a multiple-file programmable text editor based on .IR ed . .PP .I Qed operates on a copy of any file it is editing; changes made in the copy have no effect on the file until a \fIw\fR or \fIW\fR (write) command is given. The copy of the text being edited resides in a scratch area called a .I buffer. There are 56 buffers, labeled by alphabetics `a' to `z' and `A' to `Z', and the characters `{', `|', `}' and `~' (the four ASCII characters following `z'). These 56 characters are called, for notational efficiency, .I bnames. The buffers can contain any ASCII character except NUL. .PP If .I file arguments are given, .I qed simulates an .I r command (see below) on each of the named files; that is to say, the files are read into .I qed's buffers so that they can be edited. The first is read into buffer `a', the second into buffer `b', through `z', then from `A' to `Z', up to a maximum of 52 files. The optional .B \- puts .I qed in non-\c .I verbose mode (described with the .I o command). The \fB\-q\fR, \fB\-e\fR and .B \-i are equivalent to performing an initial `oqs', `oes' or `ois' command (see the .I o command below). .PP When \fIqed\fP starts up, the file named by the environment variable .B QEDFILE is read into buffer `~' and executed (i.e. read as command input), before reading in files and accepting commands from the terminal. The argument .I filename\c s are set in the buffers before the startup file is executed, so the startup file can treat the \fIfilenames\fR as arguments. The default startup file may be overridden with the \fB\-x\fR option. .PP Input to .I qed can be redirected, at any time, to come from storage such as a buffer by use of a .I special .I character such as ``\eb''. All the .I qed special character sequences are discussed in detail below; they all begin with a backslash `\\'. .PP .I Qed has a .I truth flag which is set according to the success of certain commands and which can be tested for conditional execution, and a .I count which is set to such values as the number of successful substitutions performed in an .I s command. Each buffer has associated with it a (possibly null) filename and a .I changed flag, which is set if the contents of the buffer are known to differ from the contents of the named file in that buffer. .PP Commands to .I qed have a simple and regular structure: zero or more .I addresses followed by a single character \fIcommand\fP, possibly followed by parameters to the command. These addresses specify one or more lines in the buffer. Every command which requires addresses has default addresses, so that the addresses can often be omitted. .PP In general, any number of commands can appear on a line. Some commands require that the character following the command be a separator, such as blank, tab or newline. Usually, a .I display .IR character , .IR p , .IR P , .IR l , or .I L may precede the separator, causing the resulting line to be displayed in the specified format after the command. Certain commands allow the input of text for placement in the buffer. This text can be supplied in two forms: either on the same line, after the command, or on lines following the command, terminated by a line containing only a period `\fB.\fP'. If the text is on the command line, it is separated from the command by a space or a tab. If the tab is used, it is considered part of the text. .PP .I Qed supports a limited form of \fIregular\fP \fIexpression\fP notation. A regular expression specifies a set of strings of characters. A member of this set of strings is said to be .I matched by the regular expression. Regular expressions in .I qed are delimited by enclosing them in a pair of identical characters, frequently slashes `/'. In the following specification for regular expressions the word `character' means any character but newline. Note that special character interpretation always occurs .I before executing a command. Thus, the backslashes mentioned below are those present after special characters have been interpreted. .IP 1. Any character except a metacharacter matches itself. Metacharacters are the regular expression delimiter plus < [ \fB.\fP and \e | > ^ * \+ $ when another rule gives them a meaning. .IP 2. A \fB.\fP matches any character. .IP 3. A backslash \\ followed by any metacharacter in the list given in rule 1 is a regular expression and matches that character. A backslash followed by one of ! _ { } ( ) or a non-zero digit has a special meaning discussed below; otherwise, backslashes have literal meaning in regular expressions. .IP 4. The metacharacter \e\|! matches any control character except tab or newline. .IP 5. A non-empty string .I s enclosed in square brackets [\fIs\fP] (or [^\fIs\fP]) matches any character in (or not in) \fIs\fP. In .IR s , \\ has no special meaning, and ] may only appear as the first character. A substring .IR a \- b , with .I a and .I b in ascending ASCII order, stands for the inclusive range of ASCII characters. .IP 6. A regular expression, of the form <\fIx1\fP> or <\fIx1\fR|\|\fIx2\fR|\|...|\|\fIxn\fR>, where the \fIx\fR's are regular expressions of form 1-12, matches what the leftmost successful \fIx\fR matches. .IP 7. A backslash followed by a non-zero digit .I n matches a copy of the string that the bracketed regular expression (see rule 11) beginning with the \fIn\fPth \e\|( matched. .IP 8. A regular expression of form 1-7 followed by * (\+) matches a sequence of zero (one) or more matches of the regular expression. .IP 9. The metacharacter \\\|_ matches a non-empty maximal-length sequence of blanks and tabs. .IP 10. The metacharacter \\\|{ (\\\|}) matches the empty string at the beginning (end) of an identifier. An identifier is defined to be an underscore _ or alphabetic followed by zero or more underscores, alphabetics or digits. .IP 11. A regular expression, .IR x , of form 1-12, bracketed \e\|(\|\fIx\fP\|\e\|) matches what .I x matches. The nesting of these brackets in each regular expression of an alternation (rule 6) must be identical. An alternation with these brackets may not be iterated (rule 8). .IP 12. A regular expression of form 1-12, .IR x , followed by a regular expression of form 1-11, .IR y , matches a match for .I x followed by a match for .IR y , with the .I x match being as long as possible while still permitting a .I y match. .IP 13. A regular expression of form 1-12 preceded by ^ (followed by $) is constrained to matches that begin at the left (end at the right) end of a line. .IP 14. A regular expression of form 1-13 picks out the longest among the leftmost matches in a line. .IP 15. An empty regular expression stands for a copy of the last regular expression encountered. .PP .i0 Regular expressions are used in addresses and the .I g and .I v commands to specify lines, in the .I s command to specify a portion of a line which is to be replaced, in the .I G and .I V commands to refer to buffers in which to perform commands, and in general whenever text is being specified. .PP To understand addressing in .I qed it is necessary to know that at any time there is a \fIcurrent buffer\fR and a \fIcurrent line.\fR When .I qed is invoked, the current buffer is buffer `a', but may be changed at any time by a .I b (change buffer) command. All addresses refer to lines in the current buffer, except for a special case described under the .I m (move) command. .PP Generally speaking, the current line is the last line affected by a command; however, the exact effect on the current line is discussed under the description of the command. Addresses are constructed as follows. .IP 1. The character `\fB.\fR' addresses the current line. .IP 2. The character `$' addresses the last line of the buffer. .IP 3. A decimal number .I n addresses the \fIn\fR-th line of the buffer. .IP 4. `\*q\fIx\fR' addresses the line marked with the mark name character \fIx\fR, which must be a bname. Lines are marked with the .I k command described below. It is an error for the marked line to be outside of the current buffer. .IP 5. A regular expression enclosed in slashes `/' addresses the first matching line found by searching forwards from the line after the current line. If necessary, the search wraps around to the beginning of the buffer. If the trailing `/' would be followed by a newline, it may be omitted. .IP 6. A regular expression enclosed in queries `?' addresses the first matching line found by searching backwards from the line before the current line. If necessary the search wraps around to the end of the buffer. If the trailing `?' would be followed by a newline, it may be omitted. .IP 7. An address followed by a plus sign `+' or a minus sign `\-' followed by a decimal number specifies that address plus (resp. minus) the indicated number of lines. The plus sign may be omitted. .IP 8. An address followed by `+' or `\-' followed by a regular expression enclosed in slashes specifies the first matching line following (resp. preceding) that address. The search wraps around if necessary. The `+' may be omitted. Enclosing the regular expression in `?' reverses the search direction. .IP 9. If an address begins with `+' or `\-' the addition or subtraction is taken with respect to the current line; e.g. `\-5' is understood to mean `\fB.\fR\-5'. .IP 10. If an address ends with a `+' (or `\-') 1 is added (resp. subtracted). As a consequence of this rule and rule 9, the address `\-' refers to the line before the current line. Moreover, trailing `+' and `\-' characters have cumulative effect, so `\-\-' refers to the current line less 2. .IP 11. To maintain compatibility with earlier versions of the editor, the character `^' in addresses is entirely equivalent to `\-'. .PP .i0 Commands may require zero, one, or two addresses. Commands which require no addresses regard the presence of an address as an error. Commands which accept one or two addresses assume default addresses when none is given. If more addresses are given than the command requires, the last one or two (depending on what is accepted) are used. The last addressed line must not precede the second-last addressed line. .PP Typically, addresses are separated from each other by a comma `,'. They may instead be separated by a semicolon `;' in which case the current line `\fB.\fR' is set to the first address before the second address is interpreted. The second of two separated addresses may not be a line earlier in the buffer than the first. If the address on the left (right) side of a comma or semicolon is absent, it defaults to the first (resp. last) line. .PP Filename operands of commands may be made up of printing characters only. However, when the filename appears as the argument to the invocation of \fIqed\fP, non-printing characters may be included. When a filename is specified for a command, it is terminated at the first blank, tab or newline. .PP In the following list of .I qed commands, the default addresses are shown in parentheses. The parentheses are not part of the address, but are used to show that the given addresses are the default. .TP 5 ( \fB. \fR)\|a The append command accepts input text and appends it after the addressed line. `\fB.\fR' is left on the last line input, if there were any, otherwise at the addressed line. Address `0' is legal for this command; text is placed at the beginning of the buffer. .TP 5 b The change buffer command sets the current buffer to be that named. `\fB.\fR', `$' and the remembered .I filename are set to those of the new buffer; upon return to a previously used buffer, `\fB.\fR' will be set to its value when the buffer was last used. .TP 5 ( \fB. \fR)\|b[+\-\^\fB.\fP\^][pagesize][display character] The browse command provides page-oriented printing. The optional `+', `\-', or .RB ` . ' specifies whether the next, previous, or surrounding page is to be printed; if absent, `+' is assumed. .IB b . also prints several carets `^^^^^' immediately below the current line. If a pagesize is given, it is used for the current browse command and remembered as the default. The pagesize is initially 22 lines. If a display character is given, the lines are printed in the specified format, and the format is remembered as the default. Initially, `p' is the default. For .I b+ and .IR b\- , `\fB.\fP' is left at the last line displayed; for \fIb\fP\fB.\fP, it is unchanged. NOTE: The browse and change buffer commands are the same character! The two commands can be syntactically distinguished in all cases except for `b'; this ambiguity may be resolved by typing the (implicit) `+' after the `b'. .TP 5 ( \fB. \fR, \fB. \fR)\|c The change command deletes the addressed lines, then accepts input text which replaces these lines. `\fB.\fR' is left at the last line input; if there were none, it is left at the line preceding the deleted lines. If an interrupt signal (usually ASCII DEL) is received during a change command, the old lines are not deleted. .TP 5 ( \fB. \fR, \fB. \fR)\|d The delete command deletes the addressed lines from the buffer. The line after the deleted section becomes the current line; if the deleted lines were originally at the end, the new last line becomes the current line. The character after the `d' can only be one of a blank, newline, tab, or display character. Line 0 is a valid address for deletion; deleting line 0 has no affect on any lines in the buffer. .TP 5 e filename The edit command causes the entire contents of the current buffer to be deleted, and then the named file to be read in. `\fB.\fR' is set to the last line of the buffer. The number of characters read is typed if .I qed is in .I verbose mode. The \fIfilename\fP is remembered for possible use as a default file name in a subsequent \fIf\fP, \fIr\fR, \fIw\fR, or \fIW\fR command. .TP 5 E filename The .I E command is like .IR e , except that .I qed does not check to see if the buffer has been modified since the last .I w command. .TP 5 f filename The filename command prints information about the current buffer, in the format used by the \fIn\fR command. If \fIfilename\fP is given, the currently remembered file name is changed to \fIfilename\fP. If .I qed is not in verbose mode, the information is only printed if the .I filename is not specified. If it is not desired to set the .I filename, the character immediately after the f must be a newline. Otherwise, the first token (which may be the null string) on the line, after a mandatory non-empty sequence of blanks and tabs, is taken to be the .I filename. These rules apply to all .I filename\c -using commands, .I e, .I f, .I r, .I R, .I S, .I w and .I W, although some regard specification of an explicitly null \fIfilename\fP as an error. .TP 5 ( 1 , $ )\|g/regular expression/command list In the global command, the first step is to mark every line in the range which matches the regular expression. Then for every such line, the command list is executed with `\fB.\fR' initially set to that line. Any embedded newlines in the command list must be escaped with a backslash. The \fIa\fP, \fIi\fP, and .I c commands and associated input are permitted; the `\fB.\fR' terminating input mode may be omitted if it would be on the last line of the command list. The commands .I g and .I v are not permitted in the command list. If the command list is empty, `\fB.\fPp' is assumed. The regular expression may be delimited by any character other than newline. .TP 5 G/regular expression/command list In the globuf command, the first step is to mark every active buffer whose output from an .I f command (with the .I filename printed literally) would match the regular expression. (An active buffer is one which has either some text or a remembered file name.)\ Then for every such buffer, the command list is executed with the current buffer set to that buffer. In other respects it is like the global command, except that only the commands .I G and .I V are not permitted in the command list. If the command list is empty, `f' is assumed. .TP 5 h