Jump to content

TECO (text editor)

From Alfawiki
TECO
Company typeSoftware
IndustryText editing software
Founded1962
FounderDan Murphy
Headquarters
Cambridge, Massachusetts
,
United States
ProductsTECO text editor and programming language

TECO (), an abbreviation for Text Editor & Corrector, is a character-based text editor and programming language created in 1962 specifically for Digital Equipment Corporation machines. Developed by Dan Murphy at the Massachusetts Institute of Technology (MIT), TECO has since been ported to personal computers and Unix environments.

Initially called Tape Editor and Corrector, reflecting its use of punched paper tape storage on the PDP-1, the designation shifted to "Text Editor and Corrector" as it expanded compatibility with other storage media. Numerous developers extensively modified TECO, and it is historically significant as the direct predecessor of Emacs, which originated as a set of TECO macros.

Description

TECO functions both as a text editor and an interpreted programming language tailored for manipulating text. Its macro system allows sophisticated text searching and editing capabilities. Unlike regular expressions, TECO’s language is fundamentally imperative, though some implementations incorporated an "or" operator within string search commands.

The editor does not enforce formal syntax; each character represents an imperative instruction associated with a subroutine that may consume additional characters, modify the "program counter" (enabling control flow), or utilize a stack for nested parentheses. This lack of structured syntax permits actions such as jumping into comment sections without constraints.

TECO disregards case sensitivity and most forms of whitespace, except for the tab, which inserts a tabulation.

A humorous article titled "Real Programmers Don't Use Pascal" highlighted that TECO programmers often encoded their names as command sequences to investigate their effects. The piece also introduced the acronym YAFIYGI ("You Asked For It You Got It") to characterize TECO’s straightforwardness, contrasting it with more graphical WYSIWYG editors.

Impact

The renowned EMACS editor, developed by David A. Moon and Guy L. Steele Jr., was originally written as Editor MACroS using TECO. TECO’s usage expanded significantly following the creation of a DEC PDP-6 version at MIT’s Project MAC in 1964, which provided continuous on-screen text display for interactive editing. Subsequent TECO releases supported full-screen operation on DEC RS-232 video terminals such as the VT52 and VT100.

TECO was distributed across numerous DEC platforms, including the PDP-1, PDP-8 (running OS/8), the Incompatible Timesharing System (ITS) on PDP-6 and PDP-10, as well as TOPS-10 and TOPS-20 operating systems for the PDP-10. DEC included TECO in all its operating systems; for instance, the RT11 edition included support for GT40 graphical displays, while the RSTS/E version functioned as a multi-user run-time environment, effectively enabling users to operate entirely within TECO without exiting. The VTEDIT macro enabled full-screen visual editing on RSTS/E and VAX systems equipped with cursor-capable terminals, competing with contemporary editors like Emacs.

TECO continues to be part of the software suite in OpenVMS maintained by VSI, accessible through the EDIT/TECO command.

An offshoot of DEC’s PDP-10 TECO remains available online today, along with partial versions for the MS-DOS/Microsoft Windows platforms.

History

Around 1963, Daniel L. Murphy created TECO at MIT for deployment on two PDP-1 machines located in separate departments within Building 26. At that period, programmers predominantly worked offline using punched paper tape with a Friden Flexowriter, in contrast to IBM mainframe users who manipulated source code physically via punched cards featuring human-readable characters. The absence of such user-friendly features for paper tape motivated the invention of online editing.

One of the earliest editors for the PDP-1 was called "Expensive Typewriter," a simple line-based editor lacking search-and-replace capabilities, humorously named in reference to the preceding "Colossal Typewriter." Even then, the introduction of online editing significantly reduced debugging time. Another comparable tool from that era was the Expensive Desk Calculator.

TECO's initial function was to boost PDP-1 productivity by generating "correction tapes" that described editing commands to be applied swiftly to source tapes. By utilizing high-speed readers and punches, TECO produced modified tapes ready for immediate assembly and execution, thereby removing delays associated with manual tape editing.

The sophisticated searching features of TECO were developed because Flexowriter printouts lacked line numbers; thus, edits needed to be specified contextually. Its support for looping and conditional statements rendered TECO Turing-complete, allowing the creation of intricate correction tapes with minimal keystrokes.

Correction tapes, much like programs, required debugging, and straightforward global search-and-replace operations often led to errors. As a result, TECO transitioned towards online editing, providing more effective text manipulation than Expensive Typewriter despite lacking a screen display—users monitored text changes through console output commands.

By 1964, MIT implemented TECO-6 on the PDP-6, introducing real-time visual editing with screen updates reflecting buffer contents. Key contributors included Richard Greenblatt and Stewart Nelson.

In 1971, Carl Mikkelsen advanced TECO by developing a real-time editing mode utilizing Datapoint-3300 CRT terminals. Early buffer management was inefficient and monopolized CPU resources on the PDP-10. With assistance from Greenblatt in 1972, Mikkelsen redesigned buffer storage and translated macros into native PDP-10 machine code. This "control-R mode" allowed efficient real-time text editing. Additionally, Rici Liknaitski introduced input-time macros that executed during command input, enhancing the functionality of TECO's auxiliary text buffers (Q-registers). These improvements supported keybindings linked to macros, laying the groundwork for what would become Emacs.

The VMS variant originated as TECO-8 written in PDP-8 assembly language and was subsequently ported to PDP-11 assembly as TECO-11 to support early VAX/VMS compatibility environments. Subsequent adaptations led to TECO32 in VAX assembly language, which was later converted through binary translation tools (VEST and AEST) for OpenVMS systems running on Alpha and Itanium architectures.

OS/8 MUNG command

On OS/8 systems, the CCL command MUNG launched TECO to load and execute a specified .TE macro file. It supported optional command-line arguments to extend its versatility.

As a programmer's tool

During and shortly after the era dominated by punched cards, source code commonly included comments marked by marginal asterisks. When these cards were transferred into online environments, aligning these stars correctly became challenging. TECO was specifically developed to tackle this issue efficiently.

As a programming language

TECO's programming syntax is notoriously difficult to decipher. As Ed Post observed in his 1983 article "Real Programmers Don't Use Pascal," TECO commands often resemble random noise on a transmission line, where even a minor typing mistake can corrupt the program or introduce elusive errors.

Craig Finseth, author of The Craft of Text Editing, characterized TECO as a "write-only" language—once created, its code is challenging to interpret without accompanying documentation.

Nonetheless, TECO remained a robust command language, with various clones still accessible for MS-DOS and Unix systems.

Commands in TECO comprise individual characters, including control characters, with the prompt indicated by a single asterisk:

*

The escape key is represented by a dollar sign; pressing it once terminates a command expecting an argument, while pressing it twice executes the input commands:

*$$

Example code

Consider a file named hello.c containing: <syntaxhighlight lang="c">

int main(int argc, char **argv)
{
    printf("Hello world!\n");
    return 0;
}

</syntaxhighlight> A TECO session could modify the word "Hello" to "Goodbye" as demonstrated below:

TECO session explanation
*EBhello.c$$ Open the file for reading and writing with backup creation
*P$$ Read the initial page
*SHello$0TT$$ Search for the string "Hello" and display the line
*-5DIGoodbye$0TT$$ Remove five characters before the cursor ("Hello"), insert "Goodbye," and print the updated line
*EX$$ Copy the rest of the file and exit

Two sample programs from the PDP-11 TECO User's Guide demonstrate straightforward interchange sorting of the current text buffer based on each line's first character. Both "goto" and "structured" variants are provided; the latter corrects a bug to ensure proper loop termination.

Example 1

!START! j 0aua               ! jump to start, load first character into register A !
!CONT! l 0aub                ! load first character of next line into register B !
qa-qb"g xa k -l ga 1uz '     ! if A>B, swap lines and set flag in register Z !
qbua                         ! load B into A !
l z-."g -l @o/CONT/ '        ! loop back if more lines remain in buffer !
qz"g 0uz @o/START/ '         ! repeat if any swaps occurred in last pass !

Example 2

<0uz                            ! clear repeat flag !
j 0aua l                        ! load first character into register A !
<0aub                           ! load first character of next line into B !
qa-qb"g xa k -l ga -1uz '       ! if A>B, swap lines and set flag !
qbua                            ! assign B to A !
l .-z;>                         ! loop back if additional lines exist in buffer !
qz;>                            ! repeat if swaps happened during last pass !

References

External links