Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

Tutorial Guide

The full screen editor (qed) is a program which allows you to type in text, edit it and save it away in a file. The editor itself treats your text as a series of lines consisting of from 0 to 512 characters. It was designed as a program development editor first and a word processor second.

When operating on text from a file, the editor reads a copy of your file into memory (we will call this a buffer). Any changes you make to your file copy (the buffer) will not affect the original file until you issue a write command to save your buffer. Should you change your mind about saving the particular changes you have made, you may exit without saving, or you may reread a copy of the original file.

The maximum number of lines you can edit will depend on how long each line is and the amount of available memory space. The maximum number of lines in a file that may be edited is on the order of 100 000. Larger files must be split and if necessary rejoined after editing.

Getting Started

Assume you want to enter some text and save it away in a file, use:

qed

The editor will load from disk, clear your screen, then present a screen that consists of a status line at the top:

last=0  (0  ,1)  a+ b- c- d- f- i- j- l- m+ n+ s- t+ w+

a line below it for command entry, and a large text area below that.

The top line of the screen is the status line and provides information about the size of your file, where in the file you are currently located, and what editing options you have selected. This line is kept up to date by the editor. You may not enter text into this area.

The second line of the screen is the command line. It is the area where you may type editor commands which are to be executed. On a monochrome display, a solid line appears after this line. On a color display, the command line will appear in a different color than the rest of the screen.

The rest of the screen is for text. If your text is longer than or wider than the screen, then this space represents a window into your text. As you progress, you will quickly learn how to position your window to view and/or modify any part of your file.

If you wish to exit from the editor, you can quit by typing a q followed by a carriage return on the command line. If you try this later (after some text has been entered), you may be greeted with a message indicating that you have changed some text but have not saved it away. You can force an exit without saving your text by typing a carriage return to clear the error and a qq followed by a carriage return. We mention quitting here to rescue those people who jump in and then get called away before they can read the rest of the manual.

Now that we have our bearings, let's look a little closer at these three areas.

The Status Line

This line is composed of three parts. On the left, Last=0 indicates that the last line of your text is line 0. You therefore have an empty buffer (zero lines). Next to this, the numbers in brackets (0,1) indicate the current position of the cursor in the file. It is of the form (row,column). The row indicates your current line and for all but an empty buffer it will range in value between 1 and Last. On attached terminals you may find that the column number does not change.

Next on the line are your current editing options. A + (plus) after an option indicates that the option is on while a - (minus) indicates that it is off. Some options which are meant to catch your attention when on will display a flashing +. These options may be turned on and off at the command line. Some of the options are also tied in with function keys. They are toggled on/off by the indicated key.

Briefly the options have the following meaning:

a - Anchor (Alt-a)
This option will be better understood after reading the section on pattern matching. For now it is enough to know that the editor has the ability to search for text strings and leave your cursor at the string matched. Should you specify a search for the string “mouse” with this option on (a+), your cursor will be anchored to the start of the pattern matched (in this case “m”). With (a-), the cursor would be positioned at the character after the matched string “mouse” (in this case the character after the “e”).
b - Blank (Alt-b)
When viewing a piece of text on the screen, lines appear to be padded with blanks to the end of the screen. Since the editor reads files with variable sized lines containing 0 (a line containing only a carriage return) to 256 characters, you may wonder whether the blanks at the end of the line are real or not. With b+, the editor will allow you to differentiate between real blanks by displaying nulls (non-existent characters) as small centered dots.
c - Command (keypad +)
This option indicates whether your active cursor is in the command area (c+) or text area (c-).
d - Dual (Alt-d)
This option, like option anchor (a), concerns pattern matching. If off (d-) then a search for “mouse” would match the string “MOUSE”, “MoUse”, “MOUsE” and so on in your text. If on (d+), the pattern matcher differentiates between upper and lower case.
f - Fill (Alt-f)
This option when on (f+) will cause automatic filling of input lines at your defined right margin. The default right margin is column 60. Should you attempt to enter a character in this column then any preceding characters of a word will be moved to the next line. Using this option you may enter text without ever having to type a carriage return to end each line. This is extremely useful when entering documentation and letters.
i - Insert (Ins)
When on (i+), all characters typed will be inserted before the character at the current cursor position.
j - Justify (Alt-j)
This option is used in conjunction with option fill (f+). When both option fill and option justify (j+) are on then when each line is filled it will also be justified.
l - Limit (Alt-l)
This option will flash (l+) when a tagged operation is being limited between a left and right limit.
m - Meta (Alt-m)
When on (m+), meta characters are enabled during pattern matching. A meta character is a character which has special significance to the pattern matcher. For instance the character dot (.) is a meta character that will match ANY character, not just a dot. This option will be explained in greater detail later.
n - Newline (F1 or F2 keys)
Whenever a carriage return is entered in the text area while this option is on, a new line will open up after your current line to allow you to type in new text. This can be thought of as line insert mode and is similar to character insert mode (i+).
s - Save (Alt-s)
When on (s+), your buffer will be automatically saved in the file autosave after every 20 lines of input. While writing to the disk you may still continue to type up to 256 characters per line, however, your keys will not be echoed (shown on the screen) until the write is complete.
t - Tabs (Alt-t)
This option is similar to option Blank. Tab characters in your text are expanded into enough spaces to reach the next tab stop. What may appear as 4 spaces may only be one “real” character. Turning this option on (t+) will display the actual tab character as a right triangle. When option Blank is also on (b+), the spaces which pad the tab to the next tab stop will be displayed as centered dots since they do not exist within the buffer. Tabs are characters which are heavily used within C programs for indentation.
w - Wrap (Alt-w)
This option allows pattern searches to wrap around from bottom to top or top to bottom when on (w+). If off, then pattern matching will stop when it reaches the last or first line of the buffer.

The Command Line

As previously stated, this line is used for entering text to be interpreted by the editor as commands. If you have just entered the editor you should have a cursor on the left margin of your command line. There will also be an inactive cursor (rectangular block) in the text area. Whenever you type a character (excluding cursor and most function keys) it will appear where the active cursor is, and the cursor will move to the right.

Now try to enter a few commands to change your options. Most options are enabled by typing

o{option_character}+

and disabled by typing

o{option_character}-

or, they can be toggled by typing

o{option_character}~

First let's turn on option blank by typing the string ob+ followed by a carriage return. You can turn it off by typing ob- followed by a carriage return. Finally, you can toggle it by typing ob~ followed by a carriage return. A toggle causes the option to change state. If it was previously off it will be turned on and if it was previously on it will be turned off.

Should you make a typing error you may delete characters by pressing the Backspace key or may delete the entire line by pressing the Ctrl and X key simultaneously. Both of these keys work on the line containing the active cursor and are similar to the line editing keys of the command interpreter for the QNX2 operating system which this editor originated in. (The line editing in the QNX 4 shell is considerably different.)

If you type in an unknown command or do something which causes an error, an error message will be displayed on the command line and held until you type a carriage return to clear it. Try typing in “abc” followed by a carriage return to generate an error, then clear it by typing another carriage return.


Note:

You may execute any system command from the editor command line by preceding it with an exclamation mark (!).
e.g. to invoke the ls utility to display the contents of the current working directory:

!ls

or to invoke another qed editor to edit another file:

!qed  another_file

The second example will invoke another copy of the editor. When you leave you will return to this editing session.


Text Area

It is this area where your text is displayed and may be directly edited. As you have seen by setting ob+, the text area is currently empty. We are now going to enter some text and follow through some examples to illustrate the function of the various cursor and function keys. Option blank should be on for these exercises (b+).

Appending New Text (F1)

To enter the text area with the intention of appending new text, you should press the F1 key. The cursor in the text area will become active (flashing) and the command line will be cross-hatched. You will also see option newline enabled (n+) and your last and current line on the line will now be (1,1) not (0,1). The Backspace key and Ctrl-X keys behave in the same manner as they did on the control line.

Type in the following text, typing carriage return at the end of each line. We apologize to J. R. Tolkien for the misquote.

Three Rings for the Eleven-kings under the sky,
Nine for Mortal Men doomed to die,
One for the Dark Lord on his light throne
In the Land of Mordor where the shadows lie.
In the Land of Mordor where the shadows lie.

After you finish typing you will want to turn off the option newline (n-). This can be done by simply pressing the F1 key again. F1 is a toggle key. Note that option newline is disabled (n-) and the cursor is positioned at the current line or the last line typed. Please refer to the section entitled “Saving Your Text” if you wish to leave the editor and/or save your text.

Appending or Inserting Lines (F1/F2)

The F1 key appends after the current line and the F2 key inserts before the current line. Now that you have some text, let's experiment with the cursor keys. Using the four arrow keys at the right (, , , ), you can move the cursor anywhere on your text (note: If the arrow keys generate numbers, type the Scroll Lock key). Your screen will scroll if necessary. You can move off the right of the screen until your status display indicates that you are on column 512. Note that you can't move above the first line, below the last line or to left of the first character.

Using the arrow keys, position yourself on line 2 directly under the “N” of “Nine”. Press the F2 key and note that option newline is now on (n+). A new line has opened up between line 1 and line 2 and the cursor points at the beginning of this new line. Press F2 again and notice how the line will disappear if you decide that this is not the place where you want to insert a new line. Press F2 again and type in the following:

Seven for the Dwarf-lords in their halls of stone,

Now press F2 again to turn off option newline (n-) and use the cursors to position yourself on line 5 under the “I” of “In”. Type F1 (n+) to append lines after line 5 and type in the following 2 lines:

One Ring to rule them all, One Ring to find them,
One Disk to bring them all and in the darkness bind them

Now type F1 to turn off option newline (n-). The F1 and F2 keys behave identically when leaving newline mode.

Using the Del and Backspace keys

Position yourself about 10 spaces to the right of the word “throne” and type a letter. The editor will immediately lengthen your line with blanks so it can place your character where requested. You can delete these blanks to restore the text by pressing the backspace key or positioning yourself just past the “e” of “throne” and holding down the Del key. The Del key deletes the character at the cursor causing the line to Shift over.

In general, you will find the Backspace key useful for correcting new text being entered, while the Del key is useful for editing existing text. As an added advantage, the Del key saves each character it deletes. Position yourself at the start of a line and hold down the Del key. To restore the last deleted characters press the Ctrl and the Ins keys simultaneously. By holding this key down you can restore the last 256 characters deleted in this editor session. The characters need not be restored where they were deleted. They will be restored at the active cursor wherever it is, even at the command line. This can be a useful method of moving strings of characters.

Change the word “Eleven” to “Elven” in line 1 by moving the cursor to the second “e” and pressing the Del key. Now move to line 7 and position the cursor under the “D” in the word “Disk” and change this word to “Ring” by simply typing over it. Note that by default, you are always in replace mode.

Inserting text using Ins

Now that we can enter new text, replace existing characters, delete characters and re-insert deleted characters, it would be nice to complete our capabilities by inserting new characters.

Move to the word “light” in line 4 and position the cursor under the “l”. Change this word to “dark” by pressing the Del key 5 times, pressing Ins (i+), typing the word “dark” and then pressing the Ins key again to disable insert mode (i-).

Other Cursor keys which Simplify Editing

There are several more cursor keys which will simplify movement through your text as follows:

  1. Pressing Shift and Tab (back-tab), will move the cursor to the start of the current line.
  2. Pressing the Ctrl and Tab, will move the cursor to the end of the current line. Always press the Shift or Ctrl key first before Tab. The Tab key by itself will place a tab character in your text. Tab characters inserted accidentally in your text can be deleted with the Del key.
  3. A Ctrl and either the left or right arrow (, ) cursor movement keys will step over words quickly. They will always stop at the end of a line containing text. The keys are symmetrical. If you overshoot, simply go in the opposite direction.
  4. A Ctrl and either the up or down arrow (, ) cursor movement keys will move your cursor up or down four lines.

Saving your Text

At any time you may leave the text area and go to the command area by typing the large + key on the right hand side of the keyboard. Note that the right and left cursor keys, the Del key, and the Ins key will operate on the command line. Other cursor keys refer only to the text area. Write your file away by typing:

w filename

where filename is any valid pathname, followed by a carriage return.

After your file has been saved, the editor positions you back in the text area where you left off. You can now continue with the rest of the exercises or may leave the editor by typing the large + key again followed by a q. If you modify the file, the q command will not let you quit without saving your changes. If you do not wish to save your changes type qq to force the editor to exit.

Exercise


Note: To test the other cursor keys, a file exceeding the text area must be used. To create a large file named bigfile on which you can do some experimentation with the editor, try the following:
find /bin /usr/bin | xargs -n10 echo >bigfile

Position the active cursor at the command line using the large + key and enter the command:

e bigfile

The e command deletes your current buffer and reads the file into the editor creating a new buffer. Note that the editor checks to make sure any current file you are working on has been saved before proceeding. If you get a warning, type carriage return to clear the error and use the ee command to force the editor to load the new file.

ee bigfile

Your buffer now contains too many lines to display on your screen and some lines which are too wide to display in their entirety. You have a window of n lines by m characters into your text. Try using your arrow keys to move about the current screen. If you attempt to leave the screen it will automatically scroll. If you want to move faster remember the Ctrl arrow keys step over words and the Shift-Tab and Ctrl-Tab move to the beginning and end of a line.

Two common reference points in a file are its beginning and end. Press the Home key and you will find yourself back at the first line. Press the End key and you will find yourself at the last line of your buffer. A Ctrl and the Home or End key will move you to the first or last line of your current screen respectively. This means that you have a local (to the current screenfull) home and end as well as a global home and end.

To step through the file a page at a time you can use the PgUp and PgDn keys. These keys lock up at the beginning or end of your file buffer. The cursor will be left at your defined center line which defaults to line 3. If you prefer it to be the first line or another line you can change it by entering command mode (the big + key) and typing the view center command:

vc{number}

where number is between 1 and (screen length - 2). For example, to set the defined center line to line 1 enter:

vc1

Occasionally you would like to scroll the screen up or down one line without moving the cursor from its current screen line position. This can be accomplished via the Ctrl-PgUp and Ctrl-PgDn keys.

When editing programs, one of the greatest virtues of a screen editor is its ability to give you context via its full screen display. The center “5” key on the numeric keypad is designed to aid you in this respect. If you move the cursor to any line on the screen then press the 5 key (termed the center key), your screen will be redisplayed with that line positioned at your defined center line. Try positioning the cursor on one of the lines at the bottom of the screen and press the 5 key.

We have now exhausted the supplied cursor movement keys and it is time to examine the 10 function keys in more detail. QNX Software Systems has found that the odd function keys are in general easier to type and where possible has placed the more commonly used editing keys on them.

More on the F1 and F2 keys

The F1 and F2 keys as we have seen toggle the new line mode. While in newline mode, you may at any time go to the command area and execute any editor command or toggle any of the options. This includes setting option newline off instead of using the F1 or F2 keys as toggle switches. This method of entering new lines is different from most editors and much more flexible. You are not locked into an append-only mode.

For example, if you are entering text with option blank off and want to know where all your “real” blanks are, you can zip up to the command area, turn on option blank (b+) and zip back without leaving the newline mode. This facility allows you to write your file occasionally without exiting from newline mode. The editor always places you where you left off after your file has been written away.

Also, suppose you have 5 lines of text in your buffer and are half way through adding line 6 when you notice a typing error on line 2. You are free to move immediately to line 2 using the cursor movement keys, correct the error, and return again to where you left off on line 6.

In the section on “Appending or Inserting Lines”, an example had you insert a line using the F2 key and turn the newline mode off. You then moved the cursor keys to another position and appended 2 lines using the F1 key. As you will see from the following examples it was not necessary to turn the newline mode off between the two steps. Newline mode has no effect until you type a carriage return.

Try double spacing the first few lines of the bigfile file. Move to the first line of the file by pressing the Home key. Press F1 and type a carriage return and then move to the start of the second line using the cursor movement keys. Type another carriage return and continue appending a few blank lines in this manner.

You could also try the following:

  1. Appending and inserting text lines in the file.
  2. Correcting and inserting characters in the text using the Del and Ins key.
  3. Combining steps 1 and 2 without leaving newline mode.

When leaving the newline mode using either the F1 or F2 keys, the editor will delete the last blank line. Typically when appending text users will enter their last line followed by a carriage return. This will open up an unwanted hole which the closing F1 (or F2) conveniently removes. However, for your protection this automatic delete is conditional upon the line being empty.

Deleting Lines (F3 key)

Your file now has a few blank lines which you may wish to delete. F3 is the line delete key and will delete the current line. Move the cursor to the start of a blank line and press F3. Continue deleting the blank lines in this manner. Now move to a line containing text and press F3. If you wish very hard and then press Ctrl-F2 your line will reappear.

The editor stores deleted lines in a delete buffer. The Ctrl-F1 will append the last deleted single line after the current line and the Ctrl-F2 will insert the line before the current line. In this case, we inserted the deleted line because the current cursor line moved down one line when the F3 key was used.

If you delete 5 lines you can restore them one by one using Ctrl-F1 or F2. They can be deleted in one text area and “undeleted” into another area. In most cases, this can be used as a method of moving lines of text; however, a simpler method of moving blocks of lines using the F7 and F8 keys will be explained later.

Filling Lines (F4 key)

When option fill is on (f+), your lines will be broken on word boundaries based upon your current right margin. If at some time in the future you would like to change your right margin and refill your text you can accomplish this using the F4 function key. It will take the line your cursor is on and all following lines up to:

whichever occurs first.

A line may be marked as a paragraph start by typing an Alt-p. A paragraph symbol will appear at the end of the line. The Alt-p acts as a toggle allowing you to mark/unmark a line. Filling will stop at each paragraph start, that line will be indented and filling will then continue until one of the above two conditions is reached. The paragraph start is provided as a means to stop filling between two consecutive lines.

If a group of lines have been tagged as described under the F7 key, then only those tagged lines will be filled. Filling will step over each paragraph stop as described above.

Lines are filled between your left and right margins. If option justify ( toggle with Alt-j) is on (j+), then the text will also be right justified.

Centering Lines (CtrlF4)

This key will center the current line between the left and right margins. Multiple lines may be centered by tagging them as described under the F7 key.

Splitting and Joining Lines (F5/F6 keys)

Sooner or later you are going to want to split a long line or join two short lines together. The F5 key will split a line at the current cursor position into two lines. The F6 key will join the cursor line and the following line together. In practice, you normally split a line on a space and no longer want the space after the split. The F5 key checks if the character under the cursor is a space and if so, deletes it before the split. On a join, F6 checks to see if the cursor line ends in a space and, if not, appends one before joining.

If you wish to keep a space on a split or suppress the append of a space on a join, then use a Ctrl-F5 or a Ctrl-F6. These keys make no assumptions; they simply split and join. Note that the operations of split and join are symmetrical. Try splitting and joining several lines to get used to this function.

Tagging Blocks of Text (F7/F8 keys)

It is often convenient to tag a group of lines, then select an operation to perform on the lines selected. For example, earlier we mentioned a method of deleting a group of lines. Although there are several ways of accomplishing this, the most convenient way is by a tagged delete. The lines to be deleted are tagged and then deleted as a group.

There are two types of tagging.

Line Tagging

This is the simpler form and allows you to tag lines in their entirety. The selected operation applies to the whole line. For example, to delete a block of lines you would locate the first line in the series to be deleted and press the F7 key. The line is displayed in reverse-video to indicate that it has been tagged. F7 is another toggle key which sets/removes a tag, hence the line could be “untagged” by pressing F7 again. This is a more complex toggle which is also tied into block tagging, and you should pause about one second before depressing the key again to untag a line.

Now move the cursor and tag the last line to be deleted using F7. You will notice that all of the lines to be deleted in between the tagged lines now show up as inverse-video. When you set two tags, all lines between the two tagged lines are treated as a tagged block. To perform the actual delete, press the F8 key (the tag operation key). This key will prompt you for a command and typing a “d” will delete all the lines as a block. The deleted lines can be restored as a block using the Ctrl-F1 or Ctrl-F2 (probably a Ctrl-F2 since you would want to insert them before the current line).

You will find that if you delete lines one at a time the editor will restore them one at a time and if you delete them as a block they will be restored as a block. This is explained in detail in the Reference section.

The tagging of lines may also be used as a method for moving and copying blocks of lines. The F8 key has five functions:

d
(delete, already explained)
m
(move)
k
(kopy)
s
(save)
p
(print lines on $lpt)

To try the move option, find a small block of text and tag the first and last lines using the F7 key. Move the cursor to another place in the text, press F8 and respond to the prompt with an “m”. The tagged block of text will be appended after the current cursor line.

The kopy option is analogous to the move option. Tag a block of lines using the F7 keys. Move to the desired location, press F8, enter a “k” when prompted and the lines will be copied after the current cursor line. The original tagged block of text remains unchanged.

The save option will save the tagged lines into the file /tmp/group.user, where group is your current numerical group ID and user is your numerical user ID. The saved text may be restored later using the Shift-F8 key. Selecting a line paste (l) will insert the text before the line your cursor is on. You may save and restore text between different edit sessions and/or consoles.

The F4 (fill) and Ctrl-F4 (center) keys will operate on tagged lines if any have been set. If not they default to the range indicated on the section describing them.

Some things to remember when using tags:

Block Tagging

Line tagging is sufficient for most editing tasks. It falls short in those cases where you wish to operate on a block of text within a line. This occurs most frequently in the preparation of multi-column text. For example, if you wished to move the block of “C”s

AAAAAAA   BBBBBBB   CCCCCCC
AAAAAAA   BBBBBBB   CCCCCCC
AAAAAAA   BBBBBBB   CCCCCCC
AAAAAAA   BBBBBBB   CCCCCCC

DDDDDDD
DDDDDDD
DDDDDDD
DDDDDDD

under the block of “B”s you would need to tag only the “C”s, not the “A”s and “B”s. Enter the text above and position yourself on the first character of the first line of “C”s. Depress the F7 (tag key) twice in rapid succession. The first depression will tag the line and the second depression will turn on the block tag feature and set a left limit at your cursor. The characters from the first C to the end of your line will be displayed in inverse video.

Now move your cursor to the C in the lower right corner and depress the F7 key again. You need only depress it once. This will tag the last line of “C”s and set a right limit. The block of “C”s should now be displayed in inverse video. If you wish, you may adjust the line range being tagged or the limits of the tag by moving your cursor and typing the F7 key. Unlike line tagging, typing F7 again will not remove a block tag.

Now move your cursor under the first B on the line containing the first row of “D”s and depress the F8 key. You will be queried with a more extensive list of operations then a simple line delete. They are

d - delete
The tagged block will be deleted. Any text to the right will slide over to the left to fill the gap.
e - erase
The tagged block will be replaced by blanks. In the special case where there is no text to the right of the block then the text is simply deleted. This option will maintain column integrity.
k - kopy
The tagged block will be copied to the current cursor location. The original text is unchanged unless the destination overlaps the tagged block.
m - move and erase
This is a combined kopy followed by an erase.
M - move and delete
This is a combined kopy followed by a delete.
s - save
The save option will save the tagged text into the file /tmp/group.user, where group and user will be numbers. The saved text may be restored later using the Shift-F8 key. Selecting a column paste will insert the text at your cursor. You may save and restore text between different edit sessions.
p - print
Print tagged block on the printer ($lpt).

Insert Mode and Block Move and Copy

When performing a tagged block MOVE or COPY with option insert off (i-), the moved text will simply overlay any existing text. If option insert is on (i+) then the text will be inserted before the cursor. This can add considerable convenience. For example you may move the block of “C”s in front of the block of “D”s by tagging it, enabling option insert, and performing a move to the first character of the first line of “D”s. You should tag extra spaces to the right so the columns line up. After the move, delete the extra block of “C”s. It is recommended that you always check the state of option insert when performing a tagged block move.

Re-setting the Last Tagged Lines or Block

The Ctrl-F7 is a toggle which can be used to retag lines or a block. Depressing it with no tags set will restore the last tags set. Depressing it with tags set will clear all tags.

Tags are set on absolute line and column numbers and inserting or deleting lines and characters may cause your tags to move with respect to your text.

Re-executing Commands (F9/F10 keys)

These two keys are used for re-executing command line commands. The F9 key will re-execute the last command. F10 will redisplay the last command allowing you to edit it, if needed, before typing a carriage return to execute it. These functions will be more useful as you learn more editor commands in the next sections.

Tabs

The editor has tab stops set every four columns with the first tab set on column five. Typing the tab key will enter a tab character at your active cursor. When displayed on your screen the tab character will be expanded into the necessary number of spaces to move to the next tab stop. Try inserting a few tabs into your text. You can display the tab character as a right triangle by turning on option tabs (ot+). By also turning on option blank (ob+), padding spaces will be displayed as small centered dots since they do not exist within your text.

Tabs are not treated with any special significance internally. They only affect your display and cursor movement on the display. You can not position your cursor on the padding spaces following a tab, only on the tab character itself or the first real character following it.

The use of tabs rather than spaces for indentation in structured languages can save considerable typing and file space storage on your diskette.

You can change your tab settings by using the View Tab command. On the command line type:

Command gives
vt2 Tabs every 2 columns
vt4 Tabs every 4 columns
vt8 Tabs every 8 columns

Line Drawing Characters

You can redefine the Ctrl and Alt cursor keys into line drawing characters by executing a macro file as follows from the qed command line:

x /usr/lib/box.macros

Experiment by typing each Ctrl-cursor-key and Alt-cursor-key within the editor. The Home, PgUp, PgDn, End and 5 key should also be used. Some of the keys will move you in the most natural direction for drawing a box, however, the Ctrl- will not move beyond the last line of your file buffer. You can press carriage return to open up room.

Margins

The editor maintains a left margin which determines the point a carriage return will return to and a right margin which determines the point at which filling will occur.

Moving Your Margins (Shift F1 to F6)

A Shift-F1 will set your left margin at your current cursor position and a Shift-F2 will set your right margin at your current cursor position. Shift-F3 and Shift-F4 will march your left margin left or right while a Shift-F5 and Shift-F6 will march your right margin left or right.

Auto Fill and Your Right Margin

Go to the command area (using the large + key) and enable option fill with the command of+ or toggle it on with the Alt-f key combination. In the text area, append the following ten lines (taken from “The Princess Bride” - William Goldman) as one long line. Do not type a carriage return.

The year Buttercup was born, the most beautiful
woman in the world was a French scullery maid named
Annette. Annette worked in Paris for the Duke and
Duchess de Guiche, and it did not escape the Duke's
notice that someone extraordinary was polishing the
pewter. The Duke's notice did not escape the notice of
the Duchess either, who was not very beautiful and not
very rich, but plenty smart. The Duchess set about
studying Annette and shortly found her adversary's
tragic flaw. Chocolate.

You will find that the editor will automatically take any partially typed word and move it to the next line when the cursor column exceeds 60, which is your default right margin. This feature allows you to type continuously without having to closely watch the screen. You can change your right margin using the View command which will be described shortly.

Auto Justify

Go to the command area and enable option justify with the command oj+ or toggle it on with the Alt-j key combination. In the text area, append the following lines.

Prince Humperdinck was shaped like a barrel. His chest
was a great barrel chest, his thighs mighty barrel
thighs. He was not tall but he weighed close to 250
pounds, brick hard. He walked like a crab, side to side,
and probably if he had wanted to be a ballet dancer, he
would have been doomed to a miserable life of endless
frustration.

You will find that the editor automatically justifies each line with your right margin when it fills. This option is only active when option fill is enabled.

Indenting and Your Left Margin

A Ctrl-b will begin an indent of four spaces (increase your left margin by four) and a Ctrl-e will end an indent (decrease your left margin by four). Append the following 6 lines, holding down the Ctrl and typing a b or e for Ctrl-b and Ctrl-e.

The year Buttercup turned ten,
Ctrl-bthe most beautiful woman lived in Bengal,
Ctrl-bthe daughter of a successful tea merchant.
This girl's name was Aluthra,
Ctrl-eand her skin was of a dusky perfection
Ctrl-eunseen in India for eighty years.

You should note that your left margin only determines the point you will return to on a carriage return. You may use your cursor keys to move to the left of an indent.

Line Flags

Overstrike Flag (Alt-o)

This will flag the end of the current line with a left arrow character. When this line is written, the record separator will be replaced by a carriage return. As a result, when this line is printed, no linefeed will be issued and the following line will overstrike this line. This flag is automatically set when reading source lines which terminate in carriage returns rather than record separators. This allows reading and editing the output of DOC files which have underlining and/or boldfacing. (DOC is a document markup language which was used for the original QNX 2 manuals and which was also offered as a product by QNX Software Systems.)

Continuation Flag (Alt-c)

This will flag the end of the current line with a bidirectional arrow character. When this line is written, the record separator will be suppressed. As a result, the next line will be continued (joined) with this one. When the editor reads a line of greater than 512 characters it will automatically split the input line and set this flag on the split line. This allows for the editing of files containing very long lines.

Paragraph Flag (Alt-p)

This will flag the end of the current line with a paragraph symbol. This is used by the fill key (F4).

Some Simple Editor Commands.

You should now be able to create new files, edit existing files (e filename) and write them away (w filename). Up until now you have had little reason to leave text mode to go to command mode to execute editor commands. The next sections will introduce you to some useful editor commands.

Learn Mode

If you have a sequence of keys which you enter often, you may wish to learn them once and assign them to a single key. Let's assume that you wish to learn the string “Copyright (c) 1998”. The next time you are about to enter it, type a Ctrl-Minus sign on the keypad and enter a Ctrl-a when prompted for the key to learn. Type in your text then signal the end of learn mode by typing a Ctrl-Break. From this point on each time you enter a Ctrl-a it will be replaced by the learned input sequence.

It is possible to learn very long and complex sequences consisting of text, cursor movements and commands.

Absolute Line Positioning

The Home, End, PgUp and PgDn keys allow you a coarse means of moving through a buffer, however, if you want to be in the middle of a thousand line buffer they are very awkward to use. If you go to the command line and type in the number of the line you want to go to (followed by a carriage return to execute) the editor takes this as a command to move your cursor to that line. This gives you the ability to move through the file in absolute terms. For example, if a compiler issues an error for line 458 of a source file then upon reading that source file with the editor you can go right to that line.

Simple Pattern Matching

When editing a file, you often want to be able to say “Find me an occurrence of this string” so you can work on it without knowing precisely where it is. This is especially true when working from a paper listing in which you know the text string you want to edit, but probably not its line number. In the editor you can find a string simply by enclosing it in slashes on the command line. The command /son/ will cause a search to be made for the string “son”. If option dual is off (od-) then the matching will be case insensitive and /son/ will match “SON”, “SoN”, “sON” and so on. It will also match a line containing “personal” since it contains an instance of “son”.

Searching begins at the character after your cursor, resulting in the editor finding the next occurrence of your pattern. If the editor searches down to the end of the buffer without finding your pattern and option wrap is on (w+) it will continue the search at the first line of the buffer and continue until it reaches and tries your current line from behind. If your pattern is not found, an error will be generated.

Assuming you match a line containing your pattern, then that line will become your current line and your cursor will either point to the first character of the string matched (a+) or the character after this string (a-). The default is option anchor enabled (a+); however, if you are adding commas to the end of words you may prefer to switch to a-.

Enclosing a pattern in question marks instead of slashes will cause a search to be made backwards through your buffer. Therefore ?son? will search for the first occurrence of the string “son” starting at the character before the cursor. If the editor searches backward to the beginning of the buffer without finding the pattern and option wrap is on (w+) it will continue searching backwards from the end of the buffer. Again if your pattern is not found an error will be generated.

The editor is careful always to remember the last pattern you specified. Typing // will cause a search for the last pattern specified. This can save typing when looking for multiple occurrences of a long pattern. An even faster method would be to use the F9 key to re-execute the last command.

Up until now we have used the words string and pattern interchangeably. Although the editor can search for simple strings of characters like /The quick brown fox/ they are a subset of a more powerful pattern matching facility. This facility is enabled by the option metacharacters (om+) when you define a pattern. When enabled the characters ., @, $, ^,*, /, ?, and [ have a special meaning. For instance, a dot (.) is a pattern which matches any character. The pattern /a.c/ would match an occurrence of a string containing an “a” followed by any character followed by a “c”. The meanings of these characters are explained in detail in the reference manual chapter. Unless you intend to read this you should turn off option metacharacters (om-) or prefix all special characters with a backslash character in your pattern. When prefixed by a backslash the special characters mentioned above lose their special meaning. A /cat\./ will only match the string “cat.” regardless of the state of option m. If you want to match a backslash you must type two of them. A /a\\b/ will match the string “a\b”. For non-alphanumerics the rule is simply this. If a character is preceded by a \ then remove the backslash and take that character literally. This allows you to specify a slash in your pattern. A /total\/number/ will match the string “total/number”. The slash is protected and not taken as the pattern delimiter.

For alphanumerics the rule is slightly more involved. If the two characters following the backslash are hexadecimal (0 to 9 or A to F) then the whole sequence is taken as one character which has the hexadecimal value indicated. A /\07/ is a pattern consisting of the single character whose hexadecimal value is 07. A /\z/ is just a “z” while a /\bc/ is the character whose hexadecimal value is 0xBC. If this seems complex or confusing you probably don't need this ability. Just remember to type two back slashes to get one and that you can match a slash (or a ? if you scan backwards) by prefixing it with a backslash.

File I/O Commands

As we have already seen, we can read a file into the editors buffer with the e command

e  filename
ee filename

and write out our buffer to a file with the w command.

w  filename

Whenever you read a file with the edit command (e) three things actually occur:

  1. Your current buffer is purged. However, your delete buffer is kept, allowing you to delete from one file and undelete into another.
  2. The filename you specified is memorized.
  3. The contents of the file are read into your empty buffer.

In each example we have specified the filename that the command should operate upon. This is not always necessary. Should you omit the filename it will default to the filename of the last file you specified with your e command. Therefore,

e report

followed by a

w

will have the write command write to the file “report”. Likewise, an

e

will simply re-read the last file edited. This is often used when you bungle something and want a fresh copy. Note that in this case you will probably have to issue an

ee

command to indicate that your unsaved buffer should be overwritten. For your protection a simple e will not destroy an unsaved buffer.

If you want to check the name of your current file, you can issue the file command:

f

which will display it in the command area. You can change it (or define it) by following the command with a filename:

f  file1

This will define your current filename as file1.

It is often useful to read another file into a non-empty buffer after some specified line. This can be accomplished with the r command; e.g. to read the file file2 into the buffer after the current line:

r  file2

The command may be prefixed by a number (or pattern search) to explicitly indicate a particular line; e.g. to read file2 after the 10th line in the text buffer:

10r  filename

Similarly, to read file2 after the line containing the next occurrence of “end” in the text buffer:

/end/r filename

The read (r) command does not affect the current filename. If you do not specify a filename after r the editor will read another copy of the current file into your text buffer.

It is also possible to prefix the write (w) command with a line number or range of lines to write.

Some examples follow.

Write all lines:

w filename

Write line 33 only:

33w filename

Write lines 1,10:

1,10w filename

Write all tagged lines:

#w filename

Finally, you can append to a file by specifying the write append command which is of the same form as the write command:

wa filename

This is useful when you wish to build a new file based upon lines or blocks of lines from your current file (or many files), for example:

The View Command

Users with a color display can change the color of the three display areas using the view attribute command.

va{area}{foregroundcolor} {backgroundcolor}

where:

{area}= Indicates:
1 the status line
2 the command line
3 the text area

and:

{foregroundcolor} or {backgroundcolor}
are color numbers between 1 and 15 inclusive

Executing System Commands

Any QNX command may be executed from within the editor by preceding it with an exclamation mark (!).

For example, to list the contents of the current working directory:

!ls

or to edit the file another_file:

!qed  another_file

After executing the QNX command, the editor will pause, waiting for the user to type carriage-return before redisplaying the screen. If you type two exclamation marks (!!) the screen clear and pause will be suppressed allowing you to invoke commands via macros in a hidden manner.

Note that Ctrl-Z is recognized within the editor and will bring up an interactive shell allowing you to execute multiple commands. To return to the editor type a Ctrl-D or issue the shell exit command to terminate the new shell.

Epilogue

At this point you should be able to perform most editing tasks. However, this introduction has hit on only a few of the editor commands and interested users are strongly urged to read the reference section, especially if they are interested in defining their own function key operations.