Video TECO User's Guide
First Edition August 1986
Revision 2.0 May 1987
Revision 2.1 March 1988
Revision 2.2 September 1988
Revision 2.3 February 1989
Revision 2.4 October 1993
COPYRIGHT (c) 1985 - 1993 BY
PAUL CANTRELL & J. M. NISHINAGA
SUDBURY, MA 01776
ALL RIGHTS RESERVED
Information in this document is subject to change without notice and
does not represent a commitment on the part of the authors. The software
described in this document is furnished under a license agreement or
nondisclosure agreement. The software may be used or copied only in accordance
with the terms of the agreement. This software or any other copies thereof, may
not be provided or otherwise made available to anyone other than the licensee.
Title to and ownership of this software remains with the author.
Table of Contents
Chapter 1
TECO is a text editing program that runs on most Digital Equipment Corporation
operating systems. Versions currently exist for the PDP-8, PDP-11, PDP-10, and
VAX[1] computers systems. While there are
some differences between various versions of TECO, they are, in general, quite
compatible with each other.
TECO has been a popular text editor not only because its command set is elegant
and powerful, but because TECO commands provide for an extension language that
allows the user to accomplish very complex editing tasks in the same commands
that he uses for normal editing.
Several TECO editors in the past have had extensions made so that TECO
macros could control the terminal screen. The resulting screen editors
did not have TECO syntax while in the screen edit mode. Typically they had one
syntax for interactive editing with immediate feedback on the screen, and then
a sub-mode which allowed access to TECO commands.
Video TECO is an attempt to create a much better screen based version of TECO.
It was designed to be an interactive screen based version of TECO from the
start, and therefore can provide immediate interactive execution of TECO
commands unlike previous screen based TECO editors.
Another difference between Video TECO and other versions of TECO is the way it
buffers files. The original TECO editors were created when computer systems
were very memory limited, and were therefore optimized to run in small memory
configurations. One way that this was accomplished was that TECO was a
pipeline editor. Text was read from the input file into an edit buffer,
and then written out to the output buffer. The only part of the file which was
resident was the edit buffer, and this was typically kept quite small. Once
text was paged out to the output file, it could not be called up again without
writing out the entire contents of the files, and then re-reading to the point
in question.
Because modern computer systems are not normally memory limited, Video TECO has
adopted the more current approach of keeping the entire file in memory at once.
This allows much more flexibility in the way the user can edit his file.
Indeed, unlike other TECO editors, Video TECO allows you to have multiple files
loaded for editing simultaneously, and these are all kept in memory while the
editor is active.
This manual is intended to provide both a reference and tutorial for the
inexperienced user, and also to provide a guide for the experienced TECO user
who wishes to determine the differences between Video TECO and classic TECO
editors.
Video TECO is currently ported to the following computer systems:
* UNIX (MASSCOMP RTU(TM))
* UNIX (Integrated Solutions 4.2 BSD)
* UNIX (Sun Microsystems)
* UNIX (Alliant Computer Systems' CONCENTRIX(TM))
* UNIX (Apple Computer's AUX(TM))
* UNIX (Digital Equipment Corporation ULTRIX)
* UNIX (System V.3, V.4)
* UNIX (HPUX)
* UNIX (OSF)
* MAC OS (Apple Computer's native MacIntosh(TM) Operating System)
* VAX/VMS (Digital Equipment Corporation)
There are several conventions used in this manual that the user should be aware
of. Some of the characters used in TECO are not normally printable characters,
and are often printed in some equivalent form. For instance, TECO commands are
terminated with the ESCAPE character, ASCII code 27(decimal). Since the ESCAPE
character does not have a printable representation, historically it has always
been echoed in TECO as a dollar sign. Therefore, when you see a dollar sign in
this manual, it should be interpreted as an escape character, not a dollar
sign.
Control characters are another example of characters which do not have
printable representations. The standard practice for printable representation
of control codes is to print them as a caret followed by the printable
character code. Thus Control-A is printed as ^A, Control-B as ^B, etc. In some
cases the reader will have to detect this by the context of the paragraph,
however every attempt will be made to explicitly mention when this is the case.
Video TECO responds to certain control codes in an immediate fashion outside of
the command parser. These are necessarily operating system dependent. However,
at this time Video TECO is ported to both VMS and Unix, and the behavior is
identical on both of them.
The rubout code (ASCII 127) causes the previous character to be deleted, as if
it had never been typed.
The rubout word code (^W) deletes a word of input, where word is
typically delineated by some white space such as a space, tab, or newline.
However, when rubbing out TECO commands, the ^W also stops at TECO command
boundaries.
The rubout line code (^U) deletes the last line of input.
The interrupt code (^C) causes complex operations such as iterations, searches,
and macro executions to terminate at the end of the current command, and return
Video TECO to command input mode. If Video TECO should become hung for some
reason, four of these characters typed in a row will exit the editor (but all
editing will be lost).
The suspend code (^Z) is used to put Video TECO in the background and return
the user to operating system command level. This command is operating system
specific, and currently only works under Unix and VMS.
To use this feature with VMS, the user must start Video TECO up using the
/SPAWN modifier. This causes Video TECO to spawn another process to run the
editor. When ^Z is typed, the user is reattached to the original process. After
^Z, the user may return to the Video TECO process by using the DCL
attach command.
To edit a file or multiple files with the Video TECO editor, the user must
specify a command line to his operating system. While this may vary from
operating system to operating system, the basic form is:
% vteco file1 file2 ... filen
Video TECO will load each file into a successive edit buffer,
and then start with the first edit buffer showing.
The Video TECO screen has four distinct areas. These are (from bottom to top),
the echo line, the message line, the status line, and the
buffer area. Here is an example Video TECO screen:
The line on the very bottom is the echo line. The echo line
automatically wraps when you exceed the right hand margin, so it will always
hold the most recent user input. The current echo position is indicated by a
non-flashing cursor. On terminals below 2400 baud this may not appear, since
the overhead in maintaining two cursors may make the editor too slow. Although
most characters are echoed in their normal representation, there are a few
which are treated specially:
The escape character is echoed as a dollar sign, since escape itself is
interpreted as a non printing control character with special meaning by
terminals.
The tab character is normally echoed in Video TECO as a position to the
next tab stop. This means that the amount of white space inserted is dependent
on the horizontal position of the tab character. Since the echo line wraps to
arbitrary positions, Video TECO displays the tab character as a sequence of
four spaces.
The carriage return character normally causes a new line to begin.
However, since we want to display as much input as possible on the echo line,
carriage returns are echoed as the sequence <CR>.
The message line is used when Video TECO wants to inform the user of an
error or unusual condition. In the example above, the message line contains the
string:
?Cannot find 'something useful'
because the search operation has failed. There are also several
commands which the user can use to place output into the message area.
The status line is a reverse video line which contains several fields,
each displaying information of use to the user.
The first field always contains the string TECO, to identify this as the
Video TECO editor.
The second field identifies which number edit buffer is currently selected. It
has the form: <BUFFER n > , where n is the number
of the current buffer.
The third field displays the name of the edit buffer. In Video TECO, the name
of the buffer is the same as the name of the file.
The fourth field is not always displayed. If the current edit buffer has been
modified, the word (modified) appears in this field. If the current edit
buffer is a readonly version of a file, the word (READONLY) appears in
this field. For more information on readonly buffers, see the EV command.
The buffer area is the area of the screen where the file being edited
is displayed. Its size will always be the size of the terminal or window minus
the three lines required for the echo, message, and status lines. The
terminal's flashing cursor will be in this area to indicated the current edit
position (dot ).
TECO commands consist of three parts: one or two optional numeric arguments,
the command name, and one or more trailing string arguments. An example of a
TECO command which has all of these present would be a constrained
find/substitute command:
* QB,ZFSsome text$other text$$
In this example, the string "QB,Z" is a double numeric
argument, the string "FS" is the command name, the string "some
text" is the first string argument and the string "other text" is
the final string argument.
At the other side of the spectrum is the move line command:
* L$$
In this example, there are no numeric arguments at all, and so the
command will default to moving by one line. There are also no string
arguments because the move line command does not accept string
arguments.
If no leading numeric argument is specified, then TECO defaults the argument to
the number one. If two arguments are to be specified, they are
separated by a comma.
Only some commands allow the trailing string argument. If the trailing string
argument is specified, it is normally terminated by an escape. An exception to
this is if the user uses the @ modifier, in which case the string is surrounded
by delimiters.
In a classic TECO editor, the user would specify many commands in a row, and
the TECO editor would not execute any of them until two escapes in a row were
typed. Video TECO executes most commands immediately. These commands can be
erased if an error occurs. When a double escape is detected by Video TECO, the
commands are determined to be completed, and they can no longer be undone by
rubbing them out.
Some commands are either so complex, or so final, that Video TECO does not
perform them until a double escape is seen. An example of this would be the
exit command. Since there is no way that it can be undone (because at the
completion of the command, the editor is no longer running), Video TECO does
not execute it immediately. Rather, it waits for the user to type the double
escape before the exit command is processed.
To exit the Video TECO editor, you use the EX, or exit command.
This will return you to the operating system prompt. If you have modified
buffers and you have not written them out, this command may fail with the error
message "modified files exist". In this event, you can either write out
the file using the EW command, if that is what you intended, or you can
supply a minus one argument to the EX command (-1ex ) to exit
without writing modified buffers.
Chapter 2
Every TECO editor has the concept of the edit buffer . The edit buffer
is that area of memory which holds the text which is currently being edited. In
a classic TECO editor, the edit buffer might contain only a portion of the file
at any one time because these editors were typically designed to run on a
memory limited machine.
The edit buffer in Video TECO always contains the entire file being edited.
Although this uses more memory than a classic TECO editor, it is a more
accepted method of operation for recently developed editors.
Since TECO is a character-oriented editor, it is important for the novice user
to understand the concept of the buffer pointer. The buffer pointer is a
pointer to the character position in the buffer that the next editing command
will affect. The buffer pointer in TECO does not point directly to a single
character, but actually points between character positions. Depending on
the command issued by the user, the characters which are affected may be to the
left or to the right of the buffer pointer.
The idea that the pointer actually points between characters is especially
confusing in Video TECO since on the screen display the flashing cursor
does appear over a character. This is a side effect of the way that
terminals operate. In most cases, the user won't really need to make this
distinction in his mind, but there are cases when remembering that this is how
TECO numbers buffer positions will make a seemingly ambiguous case
non-ambiguous.
An easy way to remember how buffer positions work in TECO is that a buffer
position refers to the number of characters to the left of the pointer. If
there are a total of ten characters in the buffer, there are eleven legal
buffer positions. Position zero is the position at the top of the
buffer, i.e., there are no characters to the left of this position. Position
ten in this case would be the final position in the buffer. If you
wanted to append text to the buffer, you would want to insert text at position
ten. An example of an edit buffer with ten characters, with the positions
labeled follows:
0V1I2D3E4O5 6T7E8C9010
Some TECO commands allow you to specify a range or block of buffer
positions. The way that this is done is by supplying two numeric arguments to
the command, separated by a comma. For example, the range 0,10 would
specify all the characters from position zero through position ten. In the
above example, this would refer to all the characters in the buffer. If you
wanted to refer only to the positions associated with the word TECO, you
would specify 6,10. Finally, if you wanted to refer to all the
positions associated with the word VIDEO, you would specify 0,5
(or 5,0 for that matter). This would rapidly get very tedious, so TECO
provides some easy ways for you to refer to some common buffer positions.
The current edit position changes as you execute TECO commands which move it.
Since it would be very difficult for a human to remember what edit position he
was now at, TECO syntax supplies the dot operand. This operand is
actually typed as a period character ('.'). The dot operand evaluates to
the number of the current edit position. To specify a range of characters which
included all the characters preceding the current edit position, you
would type 0,. . Likewise, to specify all the characters following
the current edit position, you would type .,xx where xx was the
number of the final buffer position.
The final legal position in the edit buffer at any given time depends on how
many characters are in the edit buffer. In fact, because the buffer position is
zero based, the number of the position following the final character in the
buffer is the same as the count of characters in the buffer. Therefore, this
number is doubly useful as a position and as a count of
characters.
TECO provides a shortcut character similar to dot, except that instead
of specifying the current edit position, it specifies the final buffer
position. This character is Z, and it can be used in expressions
whenever you want to refer to the end of the buffer or to the number of
characters in the buffer. For example, the expression 0,Z would specify
all of the characters in the buffer, and .,Z would specify all the
characters from the current edit position to the end of the buffer.
The final shortcut operand is the H operand. This is actually just a
compound of 0,Z, so H is just a way of specifying the entire buffer to a
TECO command. For example, probably the most common usage for H is in the HK
command. This has the effect of deleting all the characters in the buffer.
It is the fastest way to clear the edit buffer back to an empty state.
In order to perform any editing other than simply inserting sequential
characters, the user needs to be able to move the current edit position
(dot) around. TECO provides many different ways to do this in order to
provide a flexible convenient way under different editing conditions.
The C command moves the current edit position by the specified number of
characters relative to the current position. For example, the command 1C
moves the current edit position one position forward, while the command
10C would move the current edit position 10 positions forward.
If you specify a negative argument to the C command, it moves dot
backward the specified number of positions. Therefore, the command
-10C would move the current edit position backward by ten positions.
If you don't specify an argument to the C command, it defaults to 1C, so
typing repeated C commands in a row has the effect of moving the edit position
forward one character each time you type C.
The R command works exactly like the C command, except in the opposite
direction. The commands 1R and R both have the effect of moving
the edit position backward exactly one position. The command 10R would move the
edit position backward 10 characters, and the command -10R would move the edit
position 10 characters forward (because a negative argument to R
actually means forward).
The W command is a Video TECO unique command which moves the edit
position by words. Words, in this case, are defined as collections of
characters surrounded by whitespace such as spaces, tabs, and newlines.
Depending on whether you are moving forward or backward with the W command,
dot will be left at a different location within the word. While moving
forward, the edit position gets left immediately before the first character of
the word. While moving backward, the edit position gets left immediately after
the last character of the word.
As with the other positioning commands, the W command with no arguments implies
moving by one word, while specifying an argument tells how many words to move
by.
The L command allows you to move the edit position by lines. The
L command always leaves you at the beginning of a line. The argument
specifies how many lines it should move over. If you specify 1L or just
L, dot will be left at the beginning of the next line.
Negative arguments move dot backward, so the command -1L or just
-L will leave dot at the beginning of the line which precedes the line
dot is currently on.
An argument of zero will leave dot at the beginning of the current line.
While the C, R, W, and L commands have all been relative positioning commands,
i.e. they move relative to dot, the J command allows you to set the edit
position absolutely. The command takes one argument, which is the edit buffer
position to which dot should be set.
To move the edit position to the top of the buffer, you could perform the
command 0J. This would set dot to edit buffer position zero, which is
the top of the file. The command ZJ would set dot to the end of the file
since position Z always follows the final character in the edit
buffer.
The J command with no arguments is the same as 0J, i.e., it sets dot to the top
of the file.
During editing, a user often wants to position dot by searching for an
occurrence of a string within the file. The S command allows him to do
this. The S command has several forms. The most basic is:
Stext$
This will cause Video TECO to search forward from the current edit
position for the specified text string. If the text string is found, dot is
left at the position following the text string. Also, the default search string
is updated to be text. If the user then issues another search command
with no text argument (i.e. the escape character immediately follows the S
character), the search command will search for the default search string.
If you specify a single argument to the search string, that argument tells the
search command how many occurrences of the text string should be searched for.
By default, the S command with no arguments means search for one occurrence of
the string. However, if the user were to issue the command:
2Stext$
the search command would search for the second occurrence of
text after the current edit position. If the argument is negative, this
tells the search command to search backward from the current buffer
position. The search command with two arguments is a constrained search,
and will not be covered in this chapter.
The behavior of Video TECO when the string cannot be found is different from
that of classic TECO editors. Classic TECO editors would leave dot at the end
of the edit buffer. This behavior is not desirable in a screen editor, so Video
TECO leaves dot unchanged in this case, and simply issues an error message.
There are two commands for deleting text from the TECO edit buffer. These are
the D and K commands. There are an additional two commands which
use searching to specify the characters to be deleted: the FD and
FK commands.
The D command is very similar to the C command in operation,
except that instead of moving over buffer positions, it deletes them. The
command 1D or just D causes the character following dot to be
deleted. The command -1D or simply -D causes the single character
preceding dot to be deleted.
The K (for kill) command deletes lines of text, and has two basic
forms. The first form takes one argument, which is the number of lines of text
to be deleted. This works exactly like the L command except that instead
of moving over the lines, the lines are deleted. Thus, the 1K or simply
K command will delete from the current editing position up to and
including the next carriage return. The 0K command causes the text from
the beginning of the line to the current edit position to be deleted. Thus the
command sequence 0KK will always delete the entire contents of the
current line, regardless of where dot is positioned on the line.
If the argument to the K command is negative, it causes the K command to delete
the specified number of lines which precede the current edit position.
Thus -1K or simply -K will delete from the current edit position back to and
including the line which precedes the current line.
The second form of the K command takes two numeric arguments: n,mK. This
form will delete all the characters between edit buffer position n and
edit buffer position m. One example of this command would be deleting
all the characters from the beginning of the file to the current edit
position:
1,.K
Another example would be to delete all the characters in the buffer.
There are two ways to do this, with the second being the shortcut way:
0,ZK or simply HK
The FD command words exactly like the S (search) command, except
that when it finds the specified occurrence of the text, it deletes it. Thus
the command:
FDtext$
searches for the string text and then removes it from the edit
buffer. If an argument is supplied to the FD command, it specifies which
occurrence of the string should be deleted. The FD command updates the default
search string just as the S command does, and an FD command with no string
argument will search for and delete the default search string.
The FK command is another search-and-then-delete command, but it
works slightly differently from the FD command. The FK command remembers the
current edit position (dot), searches for the specified occurrence of
the specified string (or the default if no string is specified). It then
deletes all the text from the remembered dot, up to but not including
the specified text string. The reason that the deletion is not inclusive is
that firstly there are many cases where this is the action you would prefer,
and secondly, if you also wanted the searched for text to be deleted the
default search string is properly set up so that you simply issue an FD command
with no string argument and this will remove that text.
So far we have only been dealing with making changes to an existing file.
However, in reality, the most common operation is the insert operation.
This is where you want to type characters and have them appear within the file.
The insert command in TECO is the I command. It has the form:
Ithe text to be inserted$
A minor variation of the insert command is that you can initiate it by
simply typing the tab character. In this form, the tab itself is
inserted and the command then proceeds normally until you type the terminating
escape character. This is a very minor shortcut, but it does exist in all
classic TECO editors.
Another form of the insert command is when you specify a single argument to the
I command. In this form, the character whose ASCII code was supplied as the
argument is inserted. In this form, the command does not take a string
argument, so the character which follows the I will be taken as the
beginning of the next command. The following command string:
65I66I67I68I
would insert the string ABCD into the edit buffer at the current
position (because 65 is the ASCII code for 'A', etc.).
Video TECO has two commands to search for a given string and change it to a
different string. These are the FS and FR commands.
The FS command searches for the specified occurrence of the specified
string, and replaces it with the second string. For the searching aspect, FS
behaves just like the other searching commands, with the argument specifying
which occurrence should be searched for, a negative argument meaning search
backward, and a null string argument meaning search for the default search
argument. An example of the FS command is:
nFSfirst-string$second-string$
where n is the numeric argument, first-string is the string to be
searched for, and second-string is the string which will replace the first. If
the second string is null, then the effect of the FS command is identical to
that of the FD command.
The FR command is identical to the FS command except in its actions if
the second string argument is null. Rather than replace the search string with
a null string as FS would do, FR replaces it with the last (default) replace
string. Thus the sequence:
FRstring_one$string_two$FR$$
actually will replace string_one with string_two twice, because
in the second FR command both the search string and the replace string will
default to the previous settings from the earlier command.
Chapter 3
Classic TECO editors only allowed the user to edit one file at a time. This
made moving text between files, or making changes to multiple files very
difficult. Video TECO maintains multiple edit buffers which the user can switch
between to edit multiple files simultaneously.
The EB command is used to create edit buffers and to switch between
them. The command has two basic forms. However, only one of them can be used to
create new edit buffers. The command:
EBfilename.ext$
will cause an edit buffer named filename.ext to be created,
and loaded with the contents of filename.ext. If the edit buffer of that
name had already existed, the result would have been to simply make that edit
buffer be the current edit buffer. Wildcards are supported by the EB command.
The other form of the EB command can only be used to switch between edit
buffers that already exist. If you try to switch to a buffer which does not
exist, an error will occur. This form of the command takes a single numeric
argument, which is the number of the edit buffer to switch to. Each edit buffer
in Video TECO has a number associated with it strictly for this purpose. To
switch to the second edit buffer, the command of this form would look like:
2EB
Notice that there is no terminating escape. In this form, the command
completes immediately after the EB has been typed. Both forms of the command
can be undone. If you rub out the EB command, Video TECO will switch back to
the previous edit buffer.
Video TECO numbers the edit buffers that you create with the EB command
sequentially from one. Video TECO also creates edit buffers for internal use,
such as q-registers. These are numbered sequentially with negative numbers
starting with minus one. Finally, edit buffer zero is a special edit buffer
which contains a list of the current edit buffers.
The 0EB command causes Video TECO to switch to edit buffer zero. Edit buffer
zero is special in that each time you switch to it, Video TECO creates a list
of all active edit buffers, and inserts it in this edit buffer. An example of
such a list follows:
The EV command is identical to the EB command except in one respect. If it is
used to create a buffer, that buffer will be set readonly. The effect of
a readonly buffer is that you can modify its contents, but you cannot write it
out. If the buffer already exists, the EV command simply switches to it, and
does not change its readonly status.
The EW command is used to write the contents of the current edit buffer
to the disk. It takes one string argument. Normally, this argument should be
specified as null by immediately following the EW with an escape character.
This will cause the current edit buffer to be written to a disk file with the
same name as the edit buffer. If you specify a string to the EW command such
as:
EWfilename.ext$$
then Video TECO will write the contents of the current edit buffer to
the file specified in the EW command. In any case, the modified flag for
the buffer will be cleared, and this will be indicated on the status line.
Note that in the example above, the command was terminated with two escape
characters. This is because the EW command cannot be undone (once a file is
written to the disk, we can't unwrite it). In cases like this, Video TECO
forces you to use the double escape to complete the command.
The EF command is used to remove the current edit buffer. All storage
associated with the edit buffer is freed. If the edit buffer has been modified,
the EF command will fail. This can be overridden by specifying an argument of
-1 to the EF command. The EF command cannot currently be undone.
Chapter 4
There are two characters which can be used to modify the behavior of TECO
commands. The at-sign ('@') and colon (':') commands are put in front of any
arguments to a command, and change the way the commands work.
The @ modifier typically allows the user to specify text strings to Video TECO
in a different manner. Instead of being an escape terminated string, the @
command causes the string to be surrounded by two delimiters. The character
which follows the TECO command byte is the opening delimiter, and the text
string continues until a second delimiter character is seen.
As an example, assume that the user wants to input text including escape
characters, probably because he is typing in a TECO macro. If he used the
normal form of the insert command, he would have to quote every escape with the
quote (^V) command. Instead, he could use the @I command like this:
@I/this$has$escapes$in$it/
Notice a couple of things. The character which follows the @I is a
slash ('/') character. This could actually be any character the user wanted to
specify as a delimiter. The text string then continues until another slash (or
whatever the user decides to use) is typed. This terminates the insert command
just as the escape character would normally.
The colon modifier is more dependent on the command it is found with than the
AT-SIGN modifier. In general, it means execute the TECO command in an alternate
way, where alternate way depends on the command being executed.
All searching commands use the colon modifier to mean that the command should
return a value which indicates whether the search was successful or not. This
can then be used as an argument to another TECO command, typically a
conditional operator. An example would be:
:Sfred$"S0KK'
This command would search for the string 'fred', and delete the entire
line if it was found.
Here there should be a discussion about another command affected by the :
command, yet it should be one we have already described...
Q-registers are data storage registers available to the TECO user. There are 36
Q-registers in TECO corresponding to the 36 characters 0-9 and A-Z. Each
Q-register can hold a block of text and a single integer simultaneously.
Whether the user is referring to the text contents or the integer contents if
resolved by the command he used to access the data.
Video TECO implements Q-registers as internal edit buffers, so that in addition
to the Q-register commands that most TECO editors provide, Video TECO also
allows you to make a Q-register be the current edit buffer.
Text is stored in a Q-register using the X command. The X command
consists one or two arguments, the X character, and the single letter
Q-register name. Since the Q-register name is only a single character, and not
a full string, a terminating escape is not required.
If the X command is issued with no argument, or with one argument, the argument
refers to the number of lines of text from 'dot' which should be saved in the
Q-register. No argument defaults to saving one line. A negative argument saves
n lines before the edit buffer pointer. An argument of zero means
save all the text from the beginning of the line up to 'dot' in the specified
Q-register.
The X command with two arguments operates on a range of edit buffer positions
in a similar manner to the K command. In the following example:
n,mX1
all the characters from edit buffer position n through m
are copied into Q-register 1.
In all cases, the X command is non-destructive to the data in the edit buffer.
The text that is copied into the Q-register remains in the edit buffer. If the
user wishes to cut the text such that it is moved into the Q-register,
and removed from the edit buffer, he must follow the X command with a matching
K command. The X command is destructive in the sense that it deletes any
previous contents of the Q-register before the specified text is loaded into
it.
An alternate version of the X command is :X (modified by the colon argument).
This version of the X command works identically, except that the text in the
Q-register is not deleted, but rather appended to.
The G command causes the text contents of the specified Q-register to be
copied into the current edit buffer at 'dot'. 'dot' is left pointing just past
the inserted text. The Q-register remains unaffected by the command.
This command takes no leading arguments, and is simply followed by the single
character Q-register name, as in:
G1
which would copy the text contents of Q-register 1 into the edit
buffer.
Q-registers hold signed numeric data as well as textual data. The U command
must be proceeded by a single numeric value which is then loaded into the
number store area of the Q-register whose single letter name immediately
follows the U command.. Any text contents of the Q-register are unaffected. The
previous value which was stored in the Q-register is lost.
The Q command allows you to retrieve the single number stored in the
number area of the Q-register. The Q command returns a value which can be used
as part of an arithmetic expression, possibly as part of an argument to another
TECO command. Thus the Q command allows you to use Q-registers as temporary
variables in complex TECO command strings. The format of the Q command is
simply 'Q' followed by the single letter name of the Q-register:
Q1
returns as its value the numeric contents of Q-register '1'.
There are two ways you can switch into a Q-register for editing. One would be
to use the EB command and either specify the name of the Q-register
(Q-registers have names like TECO-A and TECO-1), or by specifying the edit
buffer number for the Q-register (Q-registers have negative buffer numbers). To
find out the name or buffer number, you should use the 0EB command.
A second, preferable method is to use the eq command with no string argument.
This is an enhancement to Video TECO which does not exist in classic TECO
editors. Thus:
EQ1$
causes the editor to make Q-register 1 be the current edit buffer.
There are some restrictions to what you can do when using a Q-register as the
main edit buffer:
* You can't use the Q-register you are in as the target of an X command (i.e.
XA is illegal if you are editing in Q-register A).
* You can't use the Q-register you are in as the target of a G command (i.e. GA
is illegal if you are editing in Q-register A).
* You can't use the Q-register you are in as the target of a POP command (i.e.
]A is illegal if you are editing in Q-register A).
* You can't use the Q-register you are in as the target of an asterisk command
to save the last command in the Q-register (i.e. *A is illegal when editing in
Q-register A).
* You can't use the EQqfilename$ command with the target being the Q-register
you are editing in.
Most of these are common sense, as they would obliterate the Q-register you are
in, and the Q-register would be in some undefined state during the command.
Using a Q-register this way would be very unusual, and so you probably won't
encounter it in any normal editing session.
There are several Q-registers which have special meanings. This is typically
done to allow you access to internal Video TECO data as part of a macro.
The '_' Q-register text buffer holds the current default search string. The
main advantage to doing this is that a TECO macro can save and restore the
default search string so that searches within the macro do not change what the
user had as a default search string. The typical way to do this would be to
include a
[_ and ]_
command at the beginning and end of each macro which contains search
commands. The numeric side of the underscore Q-register is reserved for future
use.
The '-' Q-register text buffer holds the current search replace string. This
allows all the same sorts of macro handling as is possible with the search
string. The numeric side of the underscore Q-register is reserved for future
use.
The numeric side of the Asterisk Q-register (*) contains the number of the
current edit buffer. This allows macros which must switch edit buffers to save
the current buffer number so that they can switch back to it when finished.
The text side of the Asterisk Q-register contains the pathname of the current
edit buffer. If you are editing /usr/teco/file.1, the G* command would insert
'/usr/teco/file.1' into the buffer at the current edit position.
Loading the text side of Q-register * renames the current edit buffer. If you
are editing /usr/teco/file.1 and you use the X command to load text into the
asterisk Q-register, the pathname of the edit buffer will be changed.
As a first step in taking full advantage of the power of TECO, the user should
realize that arguments to TECO commands are arithmetic expressions. Besides
simple statements like:
4K
you can specify complex statements such as:
(Q1*2)+(Q2/7)-(Z-./2)K
are possible. Note that the 'Q', 'Z', and '.' commands are all being
used here to return values which are part of the expression. By using
Q-registers as integer variables, it is simple to write quite complex programs
with TECO.
Classic TECO editors do not support the normal operator precedence rules that
are common in most languages. This is because of the simplicity of their
parsers. These versions simply evaluated expressions left to right unless
modified by explicit parenthesis.
Video TECO, on the other hand, supports operator precedence just as you would
expect from a normal language. While this may cause compatibility problems with
existing TECO macros, it does show that the authors really have their act
together in the parser department...
In any case, unary operators have the highest precedence, followed by multiply
and divide (* and /), followed by addition and subtraction (+ and -). This can
be overridden by the use of parenthesis where needed.
One very useful command when performing complex expression is the equals
command ('='). This command will print the decimal equivalent of the expression
in the message area of the screen. Thus the command:
2+3*4=
would print the value '14' in the message line. This is also useful
for determining the current numeric contents of a Q-registers.
Two equals commands in a row will print the results in octal, while
three equals commands in a row will print the results in hexadecimal. Thus:
1,==
would print the value 0xF, i.e. 15 in base 16.
Iterations are one of the first advanced editing skills the average user should
learn. The most common usage for an iteration is to implement a global
find/substitute. By enclosing an FS command in an iteration, it will
change all occurrences of the string following 'dot'.
Iterations are enclosed in angle brackets '<>'. They may be nested up to
255 levels deep in Video TECO. If an argument is supplied to the open angle
bracket, this specifies how many times the iteration is to execute. Thus:
4.4.1.
is a somewhat inefficient way of achieving
5L
because the body of the iteration (the 'L' command) will be executed 5
separate times. If an iteration has no argument supplied, it will loop forever,
unless jumped out of on some condition. The semi-colon command provides that
capability.
The semi-colon command provides the user with an easy way to break out of an
iteration under certain conditions. The semi-colon command can only be used
within an iteration. Attempts to use it otherwise will result in an error
message being generated. If an argument is supplied to the semi-colon command,
it will break out of the current iteration if the argument is TBS. The more
normal use of the semi-colon command, however, is with no arguments supplied.
In this case, the semi-colon command bases it's decision to break out of the
iteration on whether or not the last search command found an occurrence of the
search string. If the string was not found, the semi-colon command causes the
rest of the instructions in the iteration to be skipped, and the iteration
exited. The following example finds all occurrences of 'foo' and appends the
string 'bar' to it:
<SFOO$;IBAR$>
An easier way to do the same thing would be:
<FSFOO$FOOBAR$;>
In the first case, the insert command to insert the string 'BAR' is
executed each time the search command successfully finds 'FOO'. The final time
when 'FOO' cannot be found, the semi-colon command causes the insert command to
be skipped, and the iteration to be cleanly exited.
Likewise, the second example executes the FS command repeatedly changing all
occurrences of 'FOO' to 'FOOBAR'. Then, when the FS command cannot find another
occurrence of 'FOO', the semi-colon command causes the iteration to terminate.
TECO provides a macro capability by allowing the text contents of a
Q-register to be interpreted as a string of TECO commands. The M command
causes TECO to execute a Q-register in this fashion. The execution proceeds as
if the commands had been typed at the keyboard. Thus a macro is very similar to
a subroutine call in other languages. The advantage of macros is that complex
strings of TECO commands can be loaded into the Q-register, and then executed
by simply typing:
Mq
where q is the single letter name of the Q-register. Arguments
can be passed to macros. If you typed the command:
5Mq
and the Q-register q had as the first command:
UA
then the numeric side of Q-register A would contain the argument
value 5, and this could be used throughout the macro.
When Video TECO is first started up, it looks for an initialization file
containing default contents for Q-registers. The name is operating system
dependent. On UNIX systems the name is '.teco_ini'. On VMS it is
'TECO.INI'. Each entry in this file has a single letter Q-register name
followed by a delimiter character, an arbitrary text string followed by a
second occurrence of the delimiter character.
Video TECO loads the Q-registers with the initial text strings specified in the
TECO init file. After they have all been loaded, if Q-register '0' has been
loaded it is automatically executed before any user commands are input. This
allows the user to customize Video TECO and to set up the initial conditions of
the editor.
A simple way to create a macro is by simply typing it in as a command. TECO
provides a way to store the previous command string into Q-register after it
has been completed. The asterisk command should be typed only after a
double-escape sequence has completed the previous command. The format of the
command is:
*q
where q is the single letter name of the Q-register where the
text will be stored. The previous contents of the Q-register are lost.
Classic TECO editors typically require the *q command to be the first
command typed after a double escape. Video TECO allows *q anywhere within a
command line, and the result is that the previous command string gets saved to
the specified Q-register.
Conditional operators in TECO work exactly as conditional operators in many
high level programming languages. They allow you to test a value or expression
and conditionally execute commands based on the outcome of the test.
In TECO, the double quote character is the conditional IF
operator. The double quote is followed by a single letter which determines the
actual test to be applied. The argument to the conditional operator is the
single argument which precedes the double quote character.
If the condition specified is true, the commands which follow the conditional
operator are executed normally. However, if the condition specified is false,
TECO skips over all the following commands until it encounters an else
clause, or the close of the conditional code which is marked by a single quote.
An example of a conditional expression follows:
!LOOP!Q1-1U1Q1"GOLOOP$'
This command loops decrementing the value in Q-register 1 as long as
it contains a value greater than zero ("G). When the value is no
longer greater than zero, the OLOOP command is not executed, and the
conditional falls through the single quote command to the next command which is
typed.
If the Vertical Bar character ('|') is encountered within a conditional
expression, it represents the beginning of the else clause of the
conditional. The else clause is optional in TECO conditionals. An example of an
else clause follows:
:SFRED$"SIFound Fred$|ICan't find Fred$'
If fred is found, the command inserts 'Found Fred', ELSE
it inserts 'Can't find Fred'.
The following is a table of the available conditional operators:
Operator Meaning "C" equivalent
G Greater Than Zero > 0
L Less Than Zero < 0
T True < 0
S Successful < 0
E Equal To Zero == 0
F TBS == 0
U TBS == 0
N Not Equal To Zero != 0
C Symbol Constituent TBS
D Digit isdigit(x)
A Alphanumeric isalpha(x)
V Lower Case islower(x)
W Upper Case isupper(x)
Note that you can only test arithmetic values against zero. Thus if you wanted
to test for a specific value such as 1234, you have to do it like this:
Q1-1234"E
such that the equal to zero test only works when the original value
(Q1 in this example) is equal to 1234.
Chapter 5
Searching is used extensively in TECO to position the edit cursor. Normally,
the string that the user specifies to the search command contains a list of
normal characters. Each character specified in the search string must be
matched by a similar character in the edit buffer.
Video TECO searches default to case insensitive searches. This means
that characters in the edit buffer are considered to match characters in the
search string even if one is upper case and the other is lower case.
Wildcard searches allow the user to embed special character sequences within
the search string which match a class of character or string rather than
a single character. This allows you to create very complex search operations
without having to resort to conditional expressions to test for different
occurrences.
Perhaps the simplest wildcard to use as an example is the ^X wildcard. This is
actually the ASCII code 24, Control-X. It tells Video TECO to match any
character in this position. The user should understand that ^X requires
some character to be there, it just doesn't matter what code it is. Thus
the command:
SA^XB$
Would match the strings A+B, A-B, A*B, A/B, as well as many other
strings. While this is only moderately useful during normal editing, it becomes
invaluable when writing macros to accomplish complex editing tasks.
As already described, the ^X wildcard will match any single character, with the
requirement that the character must exist. For instance, if the last three
characters in the edit buffer were the letters 'foo', the search
string
Sfoo^X$
would not find them because it would require that some character
follow the second 'o' character. However, if the last four characters in
the buffer were the letters 'foot', then the search command would have
found this occurrence.
The Control-N wildcard matches any character except the one which
follows the ^N in the search string. Thus the search command:
Sfoo^Nt$
would find strings such as food, or fool, but not
foot..
The ^ED wildcard matches numeric digits. Thus the search string will skip over
any number of characters from the set {0,1,2,3,4,5,6,7,8,9}. There must,
however, be at least one numeric character for the search to
succeed. Note that commands like:
S^ED1$
will always fail, since the ^ED eats up all the numeric digits
insuring that there is never a '1' to match the '1' in the search
string.
The ^ES wildcard matches any number of spaces and tabs.
The ^E^E string is not actually a wildcard, but instead a modifier or mode
setting string. It causes the search operator which is normally case
insensitive to become case sensitive. Thus:
Snow is the ^E^ETIME$
would match the strings 'NOW IS THE TIME', 'Now Is The TIME', but not
'now is the time', because the final four characters are all required to match
case exactly.
The ^EA wildcard matches any alphabetic character, i.e. any upper or lower case
letter from A-Z.
The ^EB wildcard matches any separator character, where separator is defined as
any non-alphanumeric character.
The ^EC wildcard matches any symbol constituent. Although symbols vary from
computer to computer, this is currently defined to be alphanumeric plus period
(.), Dollar sign ($) and underscore (_), regardless of platform.
The ^EGq wildcard matches any character currently in the text side of
Q-register q. Note that this is a fairly slow operation, since the
evaluation must be done at run time, rather than parse time. In an iteration,
for instance, the search table cannot be specified at parse time, but rather
must be built each time through the iteration in case the contents of the
Q-register have been changed. The ^E[ construct is generally a more efficient
mechanism.
The ^EL wildcard matches any line terminator character. This is defined as
newline, carriage return, or form feed.
The ^EM wildcard causes any number of the following token to be matched. For
instance, ^EMA would match A, AA, or AAA. ^EM^EC would cause any number of
symbol constituents to match, thus ^EM^EC could match "long_symbol_name_9".
The ^ER wildcard matches any alphanumeric character.
The ^EUq wildcard matches the ASCII code contained in Q-register
q. Thus the sequence 32UA S^EUA$ would be a rather roundabout
way to search for a space.
The ^EV wildcard matches any single lowercase letter.
The ^EW wildcard matches any single upper case letter.
The ^E[a,b,c] wildcard matches any of the tokens a,b,c. Note that the
tokens can generally include wildcards, so a sequence such as
S^E[a,b,c,^ES,^EL] would search for any of the characters a,b,c, any
number of whitespace characters (^ES) or any line terminator character (^EL).
The ^E<nnn> wildcard matches the numeric code nnn. Unlike
classic TECO which just assumes the code is octal radix, Video TECO assumes
that a leading zero means octal (i.e. 010 is octal 10), a leading 0x means hex,
Both the AT-SIGN and COLON modifiers work with all forms of the search command.
The colon modifier affects all searching commands the same way. It causes them
to return a value, depending on whether or not the specified string was
found.
In the presence of the colon modifier, search strings will return zero if the
string was not found, or minus one if the string was found. Thus, the
command:
:Sfred$=
would either print 0 or -1 on the message line, depending on whether
or not the string 'fred' was found.
The AT-SIGN ('@') modifier affects how strings are specified to the search
strings. Instead of being escape terminated strings, the strings are specified
by the user by surrounding them with delimiter characters. This allows escape
to be included in the string. An example of the search command using this
modifier is:
@S?string?
where the question mark character ('?') is the delimiter. Note that if
the delimiters have no intervening characters such as:
1,?
Then the specified string is null, which means to use the default
search string.
In the case of commands which take multiple strings, such as FS, the format
is:
@FS/string1/string2/
Note that there are not two sets of strings with separate delimiters.
This means that the delimiter for the replace string cannot be different from
the delimiter for the search string.
When a user types a search command such as s, n, fs, fd, fr, etc., if he
types the search string, TECO searches for the specified search string.
However, if he does not supply a search string, TECO uses the last search
string he specified.
Video TECO remembers the default search string by storing it in Q-register '_'
(underscore). This is an enhancement which does not exist in regular TECO. This
allows the advanced Video TECO user to do some useful things.
By pushing the '_' (underscore) Q-register onto the Q-register pushdown list at
the beginning of a macro, and popping it back at the end of the macro, a macro
can use searching within the body of the TECO macro without changing the user's
default search string.
A user can examine the current search string by either switching to Q-register
'_' (for instance, he could type EQ_$), or he can insert it into his current
buffer with the G command, as well as several other ways.
Instead of affecting the default search string by using a searching command,
the user can set it by simply loading Q-register '_'. This has the effect of
loading the search string, but not actually performing any search. The user
needs to keep in mind the limitation that search strings cannot exceed 256
characters. Although it is possible to switch into the '_' Q-register and edit
the search string using regular TECO commands, the user will get rather strange
results if he tries to use search commands within the search Q-register. The
better method is to switch to some other buffer, get the contents of the search
string using the G command, edit the text, and then copy it back using the X_
command.
Chapter 6
Chapter 7
The following section lists each TECO command.
In classic TECO editors, the A command without an argument meant append.
The action performed was to append more data from the file into the edit
buffer. Since Video TECO always reads the entire file in, this function has no
meaning, and is reserved for future use. An error occurs if an attempt to use
the command in this format is made.
This command returns the ASCII code of the character in the buffer offset
argument from the current edit position. Thus, this command with an
argument of zero will return the code of the character following dot,
while -1A would return the code of the character immediately preceding dot.
This command does not take two arguments, and an error will occur if it is
attempted.
In classic TECO editors, this was a shorthand for the beginning of the buffer.
It actually meant zero, since zero always is the character position of the
beginning of the buffer. Thus B,Z meant all characters in the buffer. Given
that almost every single letter command is already assigned in TECO, and since
B saves no keystrokes over typing '0', Video TECO does not recognize this
command as classic TECO editors, and instead has reserved it as a future
command. An error will occur if the user attempt to execute it.
Currently, the B command is equivalent to -L, i.e. it moves backward over lines
the same way that the L command moves forward over them.
The 'C' command moves the current edit position (dot) a relative number
of positions. If the command would result in the edit position being moved
outside of the edit buffer, an error results, and the current position is left
unaffected.
With no arguments, the C command defaults to moving the edit position forward
one. Thus, "C" is equivalent to "1C".
The single argument specifies the number of character positions to move
dot by. If the argument is positive, dot gets moved forward. If the
argument is negative, dot is moved backward.
This command does not take two arguments, and an error will occur if it is
attempted.
The 'D' command deletes the specified number of characters, relative to the
current edit position.
With no arguments, the D command deletes the single character following the
current edit position. If the edit position is currently set to the end of the
buffer, and error occurs.
A single argument to the D command specifies how many characters relative to
the current edit position should be deleted. If the argument is greater than
zero, characters following the current edit position are deleted. If the
argument is negative, characters before the current edit position are deleted.
This command does not take two arguments, and an error will occur if it is
attempted.
The E character leads into a two character command sequence:
The EB command is used to select an edit buffer for editing. There are
two forms of the command:
This form of the command takes one string argument which is the name of the
disk file to be edited. An edit buffer is created with the same name as the
disk file, and this edit buffer becomes the current edit buffer. If the edit
buffer already exists when the command is issued, Video TECO simply makes it
the current edit buffer.
EBfilename.ext$
Edit buffers created in this manner are numbered with sequential
positive integers.
If the EB command is specified with one argument, it is an immediate execute
command to switch to a pre-existing edit buffer. An error occurs if the
argument specifies a non-existent edit buffer.
Edit buffers with positive numbers contains user files. Edit buffers with
negative numbers are TECO Q-registers. Edit buffer zero is a special buffer
which lists all the current edit buffers.
Illegal
The EC command allows you to execute non-interactive operating system commands.
This is the only legal form of the command. It takes a trailing string argument
which is the entire operating system command to be executed:
ECgrep -l enum *.c$
The output of the command is inserted into the edit buffer at the
current edit position. Although the command can be undone, only the insertion
of output into the buffer can actually be undone. Obviously, the effect the
command has had on the computer system cannot be undone by Video TECO.
Illegal.
Illegal.
The EF command closes an edit buffer. An error occurs if the buffer is modified.
With no numeric arguments, the EF command expects a trailing string argument.
If the string argument is null, the current edit buffer is deleted. Otherwise,
the string specifies which existing edit buffer is to be deleted. An error
occurs if no buffer of that name currently exists, or if the specified buffer
has been modified.
In this form, the single numeric argument specifies which edit buffer is to be
deleted. No string argument is expected. An error occurs if no buffer of that
number exists, or if the buffer is modified.
If an argument of -1 is specified, the command will complete even if the buffer
has been modified. This also means that it is impossible to delete internal
buffer -1 with this form of the command.
Illegal.
The EF command allows the user to set certain values in the editor. The EJ
command takes two numeric arguments. The first selects what is being set, and
the second argument is what it should be set to.
When the first argument is one, the second argument is set to be an alternate
escape character. This is provided mostly for keyboards which either don't have
an ESCape key, or for those that have it in a cumbersome position. The
command:
1,126EJ
would set Tilde (ASCII code 126) to act as an ESCape character. Note
that the substitution takes place early in the character processing of the
editor.
When the first argument is two, the second argument is taken to be the number
of lines (i.e. the height) of the screen. This is useful if you have resized
the window since startup, but window resize is not working. (At startup you can
specify -y <n> or -h <n>). If 2,<n>EJ works but seems to go
away again after certain operations, automatic window resizing may be
interfering.
When the first argument is three, the second argument is taken to be the number
of columns (i.e. the width) of the screen. This is useful if you have resized
the window since startup, but window resize is not working. (At startup you can
specify -x <n> or -w <n>). If 2,<n>EJ works but seems to go
away again after certain operations, automatic window resizing may be
interfering.
When the first argument is four, the second argument is the ASCII value of an
alternate delete character. This allows you to set two different characters to
act as a rubout. Commonly the delete and Control-h codes might be both useful
as rubout.
The EP command allows you to split the current window into two windows, each
containing a different edit buffer, or to collapse two windows back down into
one.
This form of the command splits the current window into two windows. The
command:
m,nEP
Splits the current window, such that a new window of m lines is
created, and edit buffer n is displayed in it. The current window must
be large enough to have m lines removed from it, and still be a viable
edit window.
Currently, Video TECO's screen optimizer breaks if any two windows are
displaying the same edit buffer. Therefore, you should be careful never to let
this situation occur.
If the EP command is specified with no numeric argument, the current window is
collapsed, and the screen space is given to one of the other visible windows.
You cannot issue this command if there is only one window showing.
Illegal
The EQ command either switches the current edit buffer to a Q-register, or
fills a Q-register with a file, depending on how it is executed. The EQ
command never takes a numeric argument.
This form of the command reads the file specified by the trailing string
argument into the specified Q-register:
EQqfilename.ext$
Reads the file filename.ext and places it in Q-register
q. The current edit buffer is left unchanged.
If the EQ command is specified as:
EQq$
it has the effect of making Q-register q become the current
edit buffer.
The ER command reads the specified file into the edit buffer at the current
edit point. The current edit position is left immediately following the
inserted file. The previous contents of the edit buffer are not disturbed
during the insertion.
This is the only legal form of the command. The command expects a trailing
string argument which is the name of the file to be read into the current edit
buffer. The contents of the file are inserted into the edit buffer as if a
single I (insert) command had been issued, i.e., the rest of the buffer is left
intact, and the current edit position is left following the inserted file.
ERfilename.ext$
Illegal.
Illegal.
The ES command allows you to scroll the screen up or down a specified number of
lines. This is useful for fine positioning text to be viewed.
This is equivalent to 1ES.
This form of the command scrolls the screen by the specified number of lines.
There is a restriction that when the scroll is complete, the current edit
position (dot) must still be visible. If the scroll operation causes dot
to move off of the screen, the scroll operation will not have the intended
result, and instead either will not function, or the screen will be refreshed
with dot at the center of the screen.
The screen is scrolled up when positive numbers are supplied, and down when
negative numbers are supplied. This is consistent with the way the screen moves
when L commands cause the screen to scroll. For example, the following command
would cause five more lines following those already displayed to become
visible:
5ES
Illegal.
This command causes the screen to be refreshed.
This is the only legal form of the command. This command is not normally
required during most interactive editing, since the screen is automatically
refreshed at the end of each keystroke anyway. However, during iterations and
macro executions, many commands are executed, but the screen is only refreshed
after all the commands are complete. By inserting the ET command into an
iteration or macro, the user can see the state of the file as the commands
execute.
For example, if the user typed the following command:
<FSstring1$string2$;>$$
all occurrences of string1 would be replaced with
string2. However, the user would normally see only the first replacement
occur. Then, as he closed the iteration and typed two escapes, the iteration
would run to completion before the screen would be updated. This is often the
desirable behavior. The user gets to see the first time through the iteration,
giving him a chance to be sure that things are working the way he wants, then
the editor continues the iteration as fast as possible, until it is complete.
Suppose, however, that the user is worried that some unintended strings might
get mistakenly replaced by this command. Rather than have to issue one FS
command after another, he could just issue:
<FSstring1$string2$;ET>$$
This would cause the screen to be repainted each time a string is replaced,
giving him a chance to see each string replacement occur.
Illegal.
Illegal.
The EV command is used to select an edit buffer for editing. It is
identical to the EB command, except that if a new edit buffer is created, it is
created readonly. Readonly edit buffers are flagged by the word
READONLY on the status line. Edit buffers created this way cannot be
written out. There are two forms of the command:
This form of the command takes one string argument which is the name of the
disk file to be viewed. A readonly edit buffer is created with the same name as
the disk file, and this edit buffer becomes the current edit buffer. If the
edit buffer already exists when the command is issued, Video TECO simply makes
it the current edit buffer without having any effect on it's readonly
status.
EVfilename.ext$
Edit buffers created in this manner are numbered with sequential
positive integers.
If the EV command is specified with one argument, it is an immediate execute
command to switch to a pre-existing edit buffer. An error occurs if the
argument specifies a non-existent edit buffer.
Edit buffers with positive numbers contains user files. Edit buffers with
negative numbers are TECO Q-registers. Edit buffer zero is a special buffer
which lists all the current edit buffers.
Since this form of the command requires that the buffer already exist, it will
not create a readonly buffer. Thus this form of the command is identical to
this form of the EB command in every respect.
Illegal.
This command is used to the write the current contents of an edit buffer to the
disk. The command is not immediate execute, so it requires two escapes to be
issued before it will execute.
This is the only legal form of the command. The command expects a trailing
string argument to be specified. If the string is null, the file which is
written is written to the same name as that of the edit buffer. Otherwise, the
string specifies the name of the file to be written:
EWfilename.ext$$
This command clears the modified status of an edit buffer.
Illegal.
Illegal.
The EX command causes Video TECO to exit, returning the user to the operating
system command interpreter. Since exiting cannot be undone, the command
requires a double escape before it will be executed.
In this form, the EX command will cause the editor to exit as long as none of
the positively numbered (non-internal) edit buffers are modified. If any
are modified, Video TECO will issue an error message and refuse to exit.
This is to prevent you from editing by mistake without writing out all files
which you have made changes to.
If the EX command is supplied with a single numeric argument of minus one:
-1EX
the editor will exit regardless of whether or not any of the edit
buffers are modified. This form of the command should be used carefully, for
the obvious reasons. A good rule of thumb would be to always execute a 0EB
command first to identify which edit buffers are modified, and that you indeed
do not want those written to the disk.
Illegal.
This command searches for the specified string, and then deletes it. It follows
all the rules of the searching commands regarding arguments, wildcards, etc.
With no numeric arguments, the FD command expects a trailing string argument
which specifies the search string. The first occurrence of the search string is
found and deleted. If no occurrences of the string can be found, an error
message is generated to that effect. If the search string specified is zero
length, the default search string is searched for.
FDstring$
Specifying a single numeric argument to the FD command sets which
occurrence of the search string should be deleted. If the argument is negative,
it indicates that the search should proceed in a reverse direction. The command
still expects a trailing string argument to specify the search string:
2FDstring$
would delete the second occurrence of string.
With two numeric arguments, the search for the string is constrained between
the two buffer locations specified by the two arguments.
If the first argument is smaller than the second, it indicates that the search
should proceed forward from the buffer position as specified by the first
argument to the buffer position as specified by the second argument.
If the first argument is larger than the second, it indicates that the search
should proceed backward from the buffer position as specified by the second
argument to the buffer position as specified by the first argument.
One use of this command would be to find occurrences of a string only
within a single subroutine in a source file. If the beginning and end of the
subroutine were loaded into Q-registers one and two respectively, the following
command would find string only within the subroutine:
Q1,Q2FDstring$
Care would have to be taken in the case of an iteration to delete
all occurrences of string from the subroutine, since the end of
the subroutine moves up by the length of string each time an occurrence
is deleted. The following iteration would work properly for that case (assuming
Q1 and Q2 already set up):
<ZU3Q1,Q2FDstring$;Q2-(Q3-Z)U2>$$
because it decrements Q2 by the length of string each time it
is found by recording Z and then computing how many characters were deleted.
This command deletes all the characters from the current edit position up to
but not including the search string.
With no numeric arguments, the FK command expects a trailing string argument
which specifies the search string. The first occurrence of the search string is
found and deleted. If no occurrences of the string can be found, an error
message is generated to that effect. If the search string specified is zero
length, the default search string is searched for.
FKstring$
Specifying a single numeric argument to the FK command sets which
occurrence of the search string should be found. If the argument is negative,
it indicates that the search should proceed in a reverse direction. The command
still expects a trailing string argument to specify the search string:
2FKstring$
would delete all the text up to be not including the second occurrence
of string.
With two numeric arguments, the search for the string is constrained between
the two buffer locations specified by the two arguments.
If the first argument is smaller than the second, it indicates that the search
should proceed forward from the buffer position as specified by the first
argument to the buffer position as specified by the second argument.
If the first argument is larger than the second, it indicates that the search
should proceed backward from the buffer position as specified by the second
argument to the buffer position as specified by the first argument.
This command searches for the specified string, and then replaces it with the
second string. It is identical to the FS command except for its behavior when
the replacement string is specified as null. It follows all the rules of the
searching commands regarding arguments, wildcards, etc.
With no numeric arguments, the FR command expects two trailing string arguments
which specifies the search string and replacement string respectively. The
first occurrence of the search string is found and replaced with the replace
string. If no occurrences of the string can be found, an error message is
generated to that effect. If the search string specified is zero length, the
default search string is searched for. If the replacement string is specified
as zero length, the default replace string is used. The command:
FRstring1$string2$FR$$
would have the effect of replacing string1 with string2 twice,
because the second FR command will default both the search and replace strings
to those as specified in the first FR command.
Specifying a single numeric argument to the FR command sets which
occurrence of the search string should be replaced. If the argument is
negative, it indicates that the search should proceed in a reverse direction.
The command still expects two trailing string arguments to be supplied:
2FR$$
would delete the second occurrence of the default search string with
the default replace string.
With two numeric arguments, the search for the string is constrained between
the two buffer locations specified by the two arguments.
If the first argument is smaller than the second, it indicates that the search
should proceed forward from the buffer position as specified by the first
argument to the buffer position as specified by the second argument.
If the first argument is larger than the second, it indicates that the search
should proceed backward from the buffer position as specified by the second
argument to the buffer position as specified by the first argument.
This command searches for the specified string, and then replaces it. It
follows all the rules of the searching commands regarding arguments, wildcards,
etc.
With no numeric arguments, the FS command expects two trailing string arguments
which specify the search and replacement strings. The first occurrence of the
search string is found and replaced with the second argument. If no occurrences
of the string can be found, an error message is generated to that effect. If
the search string specified is zero length, the default search string is
searched for. If the replacement string is specified as zero length, the effect
of the command is similar to that of the FD command. The following command
changes the first occurrence of string1 to string2:
FSstring1$string2$
Specifying a single numeric argument to the FS command sets which
occurrence of the search string should be replaced. If the argument is
negative, it indicates that the search should proceed in a reverse direction.
The command still expects two trailing string arguments to specify the search
and replace strings:
2FSstring1$string2$
would replace the second occurrence of string1 with
string2.
With two numeric arguments, the search for the string is constrained between
the two buffer locations specified by the two arguments.
If the first argument is smaller than the second, it indicates that the search
should proceed forward from the buffer position as specified by the first
argument to the buffer position as specified by the second argument.
If the first argument is larger than the second, it indicates that the search
should proceed backward from the buffer position as specified by the second
argument to the buffer position as specified by the first argument.
One use of this command would be to replace occurrences of a string only
within a single subroutine in a source file. If the beginning and end of the
subroutine were loaded into Q-registers one and two respectively, the following
command would replace string only within the subroutine:
Q1,Q2FSstring$new-string$
Care would have to be taken in the case of an iteration to delete
all occurrences of string from the subroutine, since the end of
the subroutine moves each time a replacement happens, since the two strings are
of different length. The following iteration would work properly for that case
(assuming Q1 and Q2 already set up):
<ZU3Q1,Q2FSstring$;Q2+(Z-Q3)U2>$$
because it modifies Q2 by the number of characters being added or
deleted to the buffer each time a replacement operation happens by recording Z
and then computing how many characters were added or deleted to the subroutine.
The G command retrieves text from a Q-register and inserts it at the current
edit position.
This is the only legal form of the command. The command takes a single trailing
character argument which is the name of the Q-register to be accessed. For
example, to retrieve the contents of Q-register A, one could issue the
following command:
GA
No trailing ESCape is required since the trailing argument is always a
single character, not a string. An error occurs if the character either
specifies a Q-register which is not legal in Video TECO, or a Q-register which
has not be loaded yet.
Illegal.
Illegal.
This is not actually a command, but rather a shorthand argument. It is
identical to typing 0,Z as the two numeric arguments to a command. It is useful
for commands which take a range of buffer positions when you want to specify
the entire buffer. For example, the normal way to delete the entire contents of
a buffer would be:
HK
since this tells the K (kill) command to delete all the
characters from the first buffer position to the last. Another common use would
be to load the entire edit buffer into a Q-register. For example, the
command:
HXA
would load the entire contents of the buffer into Q-register A.
The I command is used to insert characters into the current edit buffer. There
are two different forms of the insert command:
This is the normal insert command which is almost always used. The command
takes a trailing string argument which is the text to be inserted:
Inew-text-to-be-inserted$
The insert command can be modified using the atsign modifier so that
the trailing string argument is delineated by characters specified by the user,
rather than being terminated by an escape. This can be handy when text with
escapes is going to be inserted. The following example is a different way of
accomplishing the previous example:
@I/new-text-to-be-inserted/
Note that there is no trailing escape required to complete the
command, the command terminates when the matching delimiter is seen.
Another way to insert escapes is to use the quote character (^V) before each
escape which is to be inserted.
This form of the command is used to insert the character whose ASCII code is
specified in the numeric argument. No trailing string argument is accepted in
this form of the command. The following example would insert the letters ABCD
into the edit buffer:
65I66I67I68I
Illegal.
The J command allows you to absolutely position (jump) the current edit
position anywhere within the edit buffer. An error occurs if the specified
position does not exist.
In this case, the command defaults to 0J, which positions to the top of the
edit buffer.
This form of the command lets you specify a buffer position to jump to. It
would be extremely unlikely that during normal editing you would actually type
an absolute buffer position to the J command, since buffer positions would be
very difficult to keep track of. However, by storing buffer positions in
Q-registers, it is then easy to refer to the buffer positions using the
Q-register. For example, if Q-register A had previously been loaded the
location of an interesting piece of text, you could return to it by issuing the
command:
QAJ
Another very command use of this command is to get to the end of the
edit buffer. Since the Z argument always contains the number of characters in
the edit buffer, the command:
ZJ
is the normal way of positioning at the end of the buffer.
Illegal.
The K command deletes lines of text relative to the current edit position.
With no arguments, the K commands defaults to 1K, deleting text from the
current edit position through the following carriage return character.
This form of the command allows you to specify how many lines of text to
delete. The command deletes text from the current edit position through the
nth carriage return character as specified in the single numeric
argument.
If the argument is negative, the command deletes text back through the
preceding nth carriage return.
If the argument is zero, text from the current edit position back to the
beginning of the line is deleted.
In this form, the two arguments specify beginning and ending buffer positions.
The entire range of buffer positions is deleted.
The L command allows you to move the current edit position by lines, relative
to its current position. In all cases, the L command leaves the current edit
position at the beginning of a line.
With no arguments, the L command defaults to 1L, moving the current edit
position forward to the next beginning of a line.
The single argument specifies how many lines to move the current edit position
by. It is moved forward over n carriage return characters, where n is
the single numeric argument to the command.
If the argument is zero, the current edit position is moved to the beginning of
the current line.
If the argument is negative, the current edit position is moved backward over
the specified number of carriage returns.
Illegal
The M command allows you to execute TECO macros. You may pass a numeric
argument to a macro, if the first command in the macro expects an argument, it
will get the argument passed to the macro.
There is currently no way for a macro to determine how many arguments
have been passed, so it is impossible to write macros which have optional
arguments.
The M command takes a single trailing character argument which specifies which
Q-register is to be executed as a macro. The text within the Q-register is
interpreted as TECO commands. The following command would execute the contents
of Q-register A as a macro:
MA
Video TECO executes macros in immediate mode, even if the command
contained in the Q-register would normally not execute immediately during
interactive execution. For example, although iterations normally require a
double escape, making it impossible to undo by rubbing out, a macro executes
immediately even if it contains iterations. The resulting changes can be undone
by rubbing out the macro command.
Illegal.
Illegal.
The N command is a modified version of the search command. Although there was
an N command in classic TECO editors, Video TECO's N command is a little
different.
In classic TECO editors, the N command would automatically page in and out
portions of the file being edited. Thus, if the entire file did not fit into
the edit buffer, N would still search the entire file.
Since Video TECO always reads the entire file into the edit buffer, there is no
need for an N search such as classic TECO editors had. However, since Video
TECO supports multiple edit buffers, the N command was defined to search across
buffer (file) boundaries. The N command only searches through the normal edit
buffers, not through the Q-register edit buffers.
Although the numeric arguments to the N command are different from those of the
normal search command, the trailing string arguments work exactly the same way
as the normal search command. If a null trailing string argument is supplied,
the N command will use the same default search string as the other search
commands.
With no numeric arguments, the N command searches for the first occurrence of
the search string, starting at the current position in the current edit buffer,
and searches to the end of the edit buffer. If it hasn't found the string by
the end of the buffer, it automatically switches to the next edit buffer. It
then searches the entire new buffer. It keeps on switching to the next buffer
and searching until it reaches the highest numbered edit buffer. It then
switches to the lowest positive numbered edit buffer, and continues searching
through the edit buffers until it returns to the original edit buffer where the
command started. When it reaches the original edit buffer again, it searches
from the top of that edit buffer down until it gets to the original buffer
position that the command started at. If after all that, it still hasn't found
the string, a normal search failure message is displayed.
A string will not be found if it crosses an edit buffer boundary. The
string must reside entirely within one of the edit buffers.
With a single numeric argument, the N command attempts to find the Nth
occurrence of the string within the set of all edit buffers. If it does not
find all N occurrences, it fails and the current position is not changed.
With two numeric arguments the N command starts searching from the edit buffer
specified by the first argument, up to and including the edit buffer specified
by second argument.
Thus if the user types the command:
5,9Nstring$
the editor will search edit buffers 5, 6, 7, 8, and 9 looking for the
string. If there were 12 edit buffers, and the user typed the command:
9,5Nstring$
the editor would search edit buffers 9, 10, 11, 12, 1, 2, 3, 4, 5, in
that order. Note that with two arguments, the editor always stops at the first
occurrence of the search string.
Normally, the editor starts searching from the top of the edit buffer specified
in the first argument. However, if the first argument specifies the number of
the edit buffer which happens to be the current edit buffer, the search will
start from the current position, instead of from the top. This is intended to
make it easier for a macro to operate on all occurrences within a set of
buffers (otherwise it would keep finding the first occurrence in the buffer).
To write an iteration which finds all occurrences of a string in all the
buffers, and appends 'string' to it, the following would work assuming there
are 15 buffers in all:
1EBJ <Q*,15Nsearch-string$;Istring$>
because Q* always evaluates to the current edit buffer, so it always
continues searching from the present position towards the end of the final edit
buffer.
The O command allows you to execute GOTO commands within a sequence of TECO
commands. Video TECO currently only supports one form of the command:
In this form, the O command takes a trailing string argument which is the name
of the label to go to. For examples a simple loop can be constructed as
follows:
!tag!Otag$
where !tag! is a TECO label. Note that TECO labels must be
delineated by exclamation marks. An error occurs if the GOTO command is
executed, but the label as specified does not exist.
In the case of a macro execution, the destination label must be within the same
Q-register that the macro is being executed out of.
Illegal.
Illegal.
The P command changes from the current display window to the next one. Thus
typing repeated P commands steps through all the windows displayed on the
screen.
This is the only legal form of the command.
Illegal.
Illegal.
The Q command retrieves the numeric contents of a Q-register. The value can
then be applied as an argument to a TECO command.
The Q command takes a single trailing character argument, where that character
specifies which Q-register is to be accessed. An error occurs if an illegal
Q-register is specified, or if the Q-register specified does not currently
exist.
Illegal.
Illegal.
If the Q-register specified is the asterisk character ('*'), the command
returns the number of the current edit buffer. This is a Video T