Editor commands are given in the form:
The line range specifies which lines the command should operate on. It can consist of zero, one or two line addresses. If no range is specified then it will usually default to the current line. The current line is the line your cursor is on in the text area and will typically be updated by each command to reflect the last line it operated on. Check the section on each command for the exact behavior.
The following line range forms are allowed:
The elements of a line range are line addresses line and are composed of:
Each line address above may be combined with other line addresses using the + and - characters to form expressions. For example:
If you specify a line address which is outside the buffer you will get an error and the command will not be executed. The special character “|” can be used to limit the preceding line addresses to lie within the buffer (between one and $). This is very useful in defining macros. The | operator sets the condition register FALSE if the line address falls outside the buffer and needs to be limited. For example:
is a safer form of the example shown above.
Each major command consists of a single character which has been chosen to reflect its nature. For example, the character d was chosen for the delete command and the character w was chosen for the write command. This character must be in lower case.
If a command line is entered which contains a line_range but no command
then the current line is set to the last line address specified. In this case the cursor will move to line 44.
Some commands require extra information to specify their operation. For example, the Move (m) command requires the specification of the destination line address:
Other commands like the Zap (z) command represent a class of commands which are specified by sub-command characters. For example:
is a zap cursor delete command. The cd is a subcommand of the zap command and will not be interpreted as the major commands c and d. This form of subcommand is used by several editor major commands.
The editor allows you to place more than one command on a line. Each command on the line is executed sequentially from left to right. For example:
will turn on option blank followed by option tab. The command:
will delete lines one through four and then delete the last line. Note that the line range only applies to the command that it immediately precedes. Should an error occur on any command then execution will be halted and any following commands will not be executed.
Some editor commands consume all characters until the end of the line collecting their right argument. They must therefore be the last command on any line on which they occur. For example
consumes all characters until the end of the line collecting the filename.
The Full Screen Editor treats a small number of characters as special in certain situations. These characters are described in the following subsections. The only character you cannot save in your text is an ASCII NUL (hex 00).
The line separator character in QNX4 is a linefeed (hex 0A). Source files separate lines by a single linefeed character, not a carriage return. On input, whenever you enter a carriage return (hex 0D) it is mapped into a linefeed character.
When the editor reads a file it collects characters up until a linefeed, replaces the newline with a null (hex 00) and saves the collected characters as a line in your buffer. The point to note is that the linefeed is not saved. It is stripped on a read and added to the end of each line when the file is written.
In the definition of complex macros containing several lines, the lines may be separated by either a carriage return or a linefeed. The supplied macro file has adopted the convention of using the linefeed separator.
The NUL character (hex 00) is used internally by the editor to delimit strings. It is therefore not possible to save this character in your buffer. Should you attempt to enter this character, the line (text or command) will be truncated at that point.
When option meta-characters is on (m+), then these characters have a very special meaning when used within patterns (they are special only within patterns). The period (.) for example will match any character, not just a period. The meaning of these characters is explained in the section on pattern matching.
The escape character on the command line is the backslash. When it precedes a meta character in a pattern it causes that character to be taken literally. That character loses any special significance it might have normally had.
Following a backslash by two hexadecimal characters in a pattern or translate string results in a single character with the hexadecimal value specified. For example \0A is the single character whose hexadecimal value is 0A (a linefeed character).
When displayed on your screen this character will be expanded into the necessary number of spaces to move to the next tab stop. Tab stops are fixed at every four columns with the first stop set on column five. You can display tabs by turning on option tabs display (ot+).
Tabs are not treated with any special significance internally. They only affect your display and your cursor movement on the display. You can not position your cursor on the expanded spaces following the tab, only the tab character itself or the real character following it.
On input, the character with hexadecimal value FF will cause all characters up until the next record separator (newline) to be collected (no echo) in a hidden buffer, then executed as a command. Any current text on the command line is not affected. This character is used heavily by the translate command when defining macros for the various cursor and function command keys.
This character is only special on input. You can place a hexadecimal FF character in your text by using the substitute command and a \ff escape. e.g. to replace “C” with the hexadecimal character FF:
On input, the character with hexadecimal value FE will recall to the command line the last command typed. This character is used by the F9 and F10 function keys.
You can place this character in your text by using the substitute command as above.
When this character is encountered in a macro, the editor will accept a character from the keyboard. If several characters occur in a row, a maximum of that number of characters will be accepted. Entering a carriage return will always terminate input (skipping any remaining FD's) and the carriage return will be discarded.
On input, the character with hexadecimal value A3 will prevent the next character from being expanded should a translate be in effect for it. For example, the Home key has a hexadecimal value of A0, but is translated on input into the three character string:
If you would like to prevent this expansion (to enter the key's value) then you should proceed it with the - key on the numeric keypad which generates the code for the Macro Disable character. You can of course enter the Macro Disable character itself by typing the - key twice.
The editor maintains a special register called the condition register which is set to TRUE or FALSE by some of the editor commands. This register can be tested by the Branch (b) command and the Until (u) command to perform conditional execution of editor commands. These commands are commonly used in macros.
The Editor maintains a buffer for deleted characters and another buffer for deleted lines.
The character delete buffer is arranged as a stack 256 characters long. Adding a character to a full buffer will cause the oldest character to be lost. In this manner the most recent 256 characters are kept.
The editor maintains primitive commands for:
These primitives are provided by subcommands of the Zap (z) command.
The saving of the last deleted character via the Del key is performed by a macro which saves the character under the cursor in the character delete buffer before deleting it. Likewise, the restoration of a deleted character via the Ctrl-Ins key combination is based upon a macro which inserts the last character placed in the delete buffer before the current cursor position.
The editor maintains another buffer in parallel with your text buffer called the line delete buffer. This buffer has the same structure as your text buffer, however, it can not be displayed or directly operated on by the editor's many commands. Each time you delete a line via the Delete (d) command it is moved from your text buffer into your line delete buffer. You can restore deleted lines using the special forms of the Append (a) and Insert (i) commands which can move lines from the delete buffer back to your text buffer.
The moving of lines between the two buffers is slightly more complicated than is indicated above and is best explained by an example.
If you were to delete 5 lines, one at a time (say via the F3 key) it would be nice if you could undelete them one at a time so that the last line deleted was the first line restored. This is particularly nice when you delete one line too many and just want to restore the last one, not all of them. Conversely, if you were to delete a group of 100 lines as a block (say via a tagged delete) you do not want to have to restore them one at a time but want them restored as a block as well. The above two scenarios describe, from a user's point of view, the editor's implementation of the line delete buffer. Associated with the buffer is a flag which indicates whether the buffer contains a series of single line deletes or one block delete. To avoid confusion, the editor will purge the line delete buffer before adding in the following circumstances.
Put simply, if you delete lines one at a time, they are undeleted one at a time and if you delete a block of lines they are undeleted as a block. Mixing blocks or types is prevented by purging before adding, if necessary.
When working with a very large buffer it is possible for the editor to run out of memory. When this happens it will purge the delete buffer in an attempt to free up some space. You will be warned of this by a message on the command line which you must clear (like an error) by typing a carriage return. Deleting all lines in a file, then attempting to edit another large file will often generate this message. In this case you have all of the original file in memory in the line delete buffer and are trying to read another large file into the text buffer. They may not both fit!
The editor will terminate any operation gracefully at the earliest possible moment after the Break key is typed. As a result of the break, any operation may be incomplete on the range of lines specified for a command, however, no line will be left in a partially modified state. Should you break out of an Edit (e), Read (r), or Write (w) command you may only move a subset of the lines into or out of your buffer to the specified file.
After servicing the Break the editor will leave you in command state.
The editor has a very powerful pattern matching facility which will match the class of patterns known as regular expressions. Patterns are used for line searches and by the Global (g) and Substitute (s) commands. It is the editor's pattern matching facility that gives it flexibility in writing powerful macros. For example, the Ctrl left and right arrow keys are implemented by a pattern which searches for the next or previous word in your text. We will attempt to describe the patterns accepted by the editor in a very rigorous manner. It is assumed that option meta characters is on (m+) during the definition of your pattern. If it is off (m-) then the editor will only recognize the class of patterns represented by (1) and (2) below.
If number is zero or the character . (dot) then this pattern will match the null string before the current cursor position in the text area.
If number is the character t then this pattern will match the null string before the next tab stop. This can be used to turn runs of spaces into tabs. See the Substitute (s) command.
Match the string “hello” anywhere on a line:
Match the string “hello” at the start of a line:
Match the string “hello” at the end of a line:
Match a line containing only the string “hello”:
Match all trailing blanks (including zero) on a line:
Match all characters (including zero) on a line:
Match a number like “3”, “862”, etc:
Match a C language identifier:
Match a digit in column ten:
Match an empty line:
Match a line containing only blanks:
Match a line starting with a period followed by a name (such as a command in the QNX2 DOC markup language):
The pages following detail the all available editor commands, in alphabetical order.