Entering text

Entering text is always done at the position of the cursor. Any newly-typed character is added to the text at the position occupied by the cursor, after which the cursor is moved one column to the right. If this motion moves the cursor to a part of the file presently outside of the screen display, the screen is scrolled horizontally.

The edit mode determines what happens to the character that was at the position of the character just added. There are two of these modes: the insert mode and the overstrike mode. In the overstrike mode, the old character is simply replaced by the new character, hence the length of the file isn't altered, unless there was no character under the cursor to begin with. In the insert mode, the character under the cursor and all characters to the right of it are moved one position to the right and the new character gets `inserted' between the other characters. Which mode is currently selected can be seen from the status characters.

The first status character (appearing on the right side of the command line - sometimes also called the status bar) is either an I indicating that the insert mode is selected or an O for the overstrike mode. The insert mode can be selected with the Alt-I key combination while the overstrike mode can be selected with the Alt-O key combination.

There are some keys which cause some special effects when inserting text. These are the <Tab> key and the <Return> key. The tab is used to move the cursor to the next tabulated position on the screen. A tab is represented in the buffers as a single character and its interpretation depends on what tabulator position the user has selected. This is all explained in the chapter about tabs.

Since normally the presence of a tab in the file cannot be distinguished visually from the presence of several spaces, a special command is available for that purpose. If you press Alt-T, all blanks will be replaced on the screen by small open circles, and tabs are indicated by small closed circles. In addition the character with the internal representation 00 (which is rarely used in text files) is represented by a fat dot. On some systems the character with the internal representation 255 (hex FF) is represented by a colon. In this way you can always find out exactly what characters are in the file you are working on. Pressing Alt-T again reverts the screen representation back to normal. Further information about this and related commands can be found in the chapter on tabs. On some systems the above characters that are used to display the tabs etc. may not be available. In that case other characters are used. The user can find out quickly which characters these are by experimenting.

The <Return> key terminates the current line at the position of the cursor, opens a new line after the current line but before any lines that follow it, and moves all characters that were after the cursor (including the one at the same position as the cursor) to the beginning of the new line. If you want to simply insert a new line, you may press the Insert key. This key creates a new empty line just above the current line and moves the cursor to the beginning of this new line. Likewise, a new line can be created just below the current line with the Shift-Insert key combination. Both these commands are independent of which column the cursor was at previously.

The return or end-of-line character is not seen by stedi as a character. Internally each line is a separate entity, and each entity has an end automatically. This allows for considerable flexibility when writing the file with several options for the interpretation of what character should be included to indicate the end of a line.

When a file is read in, all end-of-line characters are stripped off, and each line of the file is assigned a separate line in stedi's buffer. This is done in such a way that stedi can read either UNIX conventions or the MSDOS/Windows sequence of carriage return + linefeed for indicating the end of a line. This way of handling an end-of-line in the editor buffers is the reason that when a return is typed at the end of the last line of a file, a new line isn't created yet. It is only created after a character has been entered in the new line or when a second return is pressed. If one needs to have a file with no end-of-line characters at the ends of the displayed lines, one should edit in the raw or binary mode. For more information one should consult the chapter on reading, writing and printing.

The cursor can be positioned anywhere on the screen, so there might be a question about what would happen if the cursor is at a position in virtual territory and a character is typed in. The rule is that any character typed in virtual territory remains exactly where it is in relation to the rest of the text on the screen, and stedi takes care of adding the appropriate number of spaces or new lines so that the new character becomes part of a contiguous body of text. Thus if the cursor is moved to the right past any text in a given line, and a character is inserted, enough blanks will also be inserted to make this new character the end of the line. (This can be tested with the Alt-T command on.) If the cursor is moved past the end of the file into virtual lines, and a character is added, enough lines will be created to include the new character in a line of the text. This makes the adding of new characters into the text very intuitive, and much easier than if the cursor would be restricted to the text.

There is another way of entering text into a buffer that is very convenient for macro's and stream files. The command

    "string"
given from the command line (or a macro) will enter the characters in `string' in the text. There are only very few characters that can give problems if one would like to insert them this way. One is the double quote itself. Another character is the linefeed. Finally the dollar sign can give problems as it is used to indicate a variable (see p. [*]). All these characters can be used if they are preceded by an escape character which is either the character <escape> or the backslash (for linefeeds only if the file system doesn't use the backslash as a directory separator). In addition a linefeed can be indicated by the combination \n.