TECO (text editor)
Original author(s) | Dan Murphy |
---|---|
Initial release | 1962/63 |
Type | Text editor |
TECO (/ˈtiːkoʊ/; originally an acronym for [paper] Tape Editor and COrrector, but later Text Editor and COrrector, then Text Editor Character Oriented) is a text editor originally developed at the Massachusetts Institute of Technology (MIT) in the 1960s, after which it was modified by "just about everybody".[1] TECO was a direct ancestor of Emacs, which was originally implemented in TECO macros.
Description and impact
TECO is not only an editor but also an interpreted programming language for text manipulation. Arbitrary programs (called "macros") for searching and modifying text give it great power. Unlike regular expressions, however, the language was imperative (though some versions had an "or" operator in string search).
TECO does not really have syntax; each character in a program is an imperative command, dispatched to its corresponding routine. That routine may read further characters from the program stream (giving the effect of string arguments), change the position of the "program counter" (giving the effect of control structures), or push values onto a value stack (giving the effect of nested parentheses). But there is nothing to prevent operations like jumping into the middle of a comment, since there is no syntax and no parsing.
A classic essay on computer programming, Real Programmers Don't Use Pascal, suggested that a common game for TECO fans was to enter their name as a command sequence, and then try to work out what would happen. The same essay in describing TECO coined the acronym YAFIYGI, meaning "You Asked For It You Got It" and thus being the antithesis of WYSIWYG ("What You See Is What You Get").
Richard Stallman's Emacs editor was originally implemented in TECO. (Later 1970s editors which preserved the UI and default-keybindings of the original EMACS were written in Lisp: EINE/ZWEI for the MIT CADR, then Multics Emacs for the IBM 360 in 1978. In the early 1980s, first Gosling Emacs, then GNU Emacs and Lucid Emacs, were implemented in C beneath a variant of Lisp.) TECO became well-known following a Digital Equipment Corporation (DEC) PDP-6 mainframe implementation developed at MIT's Project MAC in 1964. This implementation continuously displayed the edited text visually on a CRT screen, and was used as an interactive online editor (this was, however, neither its origin nor its originally intended mode of use). Later versions of TECO were capable of driving full-screen mode on various DEC RS232 video terminals such as the VT52 or VT100.
TECO was available for several operating systems and computers, including the PDP-1 computer, the Incompatible Timesharing System (ITS) on the PDP-6 and PDP-10 mainframe, and TOPS-10 and TOPS-20 on the PDP-10. A version of TECO was provided with all DEC operating systems; the version available for RT11 was able to drive the GT40 graphics display while the version available for RSTS/E was implemented as a multi-user run-time system and could be used as the user's complete operating environment; the user never actually had to exit TECO. The VTEDIT (Video Terminal Editor) TECO macro was commonly used on RSTS/E and VAX systems with terminals capable of direct-cursor control (e.g. VT52 and VT100) to provide a full-screen visual editor similar in function to the contemporaneously developed Emacs.
Hewlett-Packard, having bought Compaq (who bought Digital Equipment Corporation), provides TECO with the OpenVMS operating system.[2]
A descendant of the version DEC distributed for the PDP-10 is still available on the Internet, along with several partial implementations for the MS-DOS/Microsoft Windows environment.
History
TECO was originally developed at MIT[3] circa 1963 by Daniel L. Murphy for use on two PDP-1 computers, belonging to different departments, both housed in MIT's Building 26.[4] On these machines, the normal development process involved the use of a Friden Flexowriter to prepare source code offline on a continuous strip of punched paper tape. Programmers of the big IBM mainframes customarily punched their source code on cards, using key punches which printed human-readable dot-matrix characters along the top of every card at the same time as they punched each machine-readable character. Thus IBM programmers could read, insert, delete, and move lines of code by physically manipulating the cards in the deck. Punched paper tape offered no such amenities, and necessity was the mother of online editing.
An early editor for the PDP-1 was named "Expensive Typewriter". Written by Stephen D. Piner, it was the most rudimentary imaginable line-oriented editor, lacking even search-and-replace capabilities. Its name was chosen as a wry poke at an earlier, rather bloated, editor called "Colossal Typewriter". Even in those days, online editing could save time in the debugging cycle. Another program written by the PDP-1 hackers was Expensive Desk Calculator, in a similar vein.
The original stated purpose of TECO was to make more efficient use of the PDP-1. As envisioned in the manual, rather than performing editing "expensively" by sitting at a console, one would simply examine the faulty text and prepare a "correction tape" describing the editing operations to be performed on the text. One would efficiently feed the source tape and the correction tape into the PDP-1 via its high-speed (200 characters per second) reader. Running TECO, it immediately would punch an edited tape with its high-speed (60 characters per second) punch. One could then immediately proceed to load and run the assembler, with no time wasted in online editing.
TECO's then-sophisticated searching operations were motivated by the fact that the offline Flexowriter printouts were not line-numbered; therefore editing locations needed to be specified by context rather than by line number. The various looping and conditional constructs (which made TECO Turing-complete) were included in order to provide sufficient descriptive power for the correction tape. The terse syntax minimized the number of keystrokes needed to prepare the correction tape.
The correction tape was a program, and required debugging just like any other program. The pitfalls of even the simplest global search-and-replace soon became evident. In practice, TECO editing was performed online just as it had been with Expensive Typewriter (although TECO was certainly a more feature-complete editor than Expensive Typewriter, so editing was much more efficient with TECO). The original PDP-1 version had no screen display. The only way to observe the state of the text during the editing process was to type in commands that would cause the text (or portions thereof) to be typed out on the console typewriter.
By 1964, a special Version of TECO (TECO-6) had been implemented on the PDP-6 at MIT. That version supported visual editing, i.e., used a screen display that shows the contents of the editing buffer in real time, updating as it changes.[5] Amongst the creators of TECO-6 were Richard Greenblatt and Stewart Nelson.[6]
At MIT, TECO development continued in the fall of 1971. Carl Mikkelsen had implemented a real-time edit mode loosely based on the TECO-6 graphic console commands, but working with the newly installed Datapoint-3300 CRT text displays.[7] The TECO buffer implementation, however, was terribly inefficient for processing single character insert or delete functions—editing consumed 100% of the PDP-10. With Richard Greenblatt's support, in summer of 1972 Carl reimplemented the TECO buffer storage and reformed the macros as native PDP-10 code. As entering the real-time mode was by typing <cntl>-R, this was known as control-R mode. At the same time, Rici Liknaitski added input-time macros (<cntl>-]), which operated as the command string was read rather than when executed. Read-time macros made the TECO auxiliary text buffers, called Q-registers, more useful. Carl expanded the Q-register name space. With read-time macros, a large Q-register name space, and efficient buffer operations, the stage was set for binding each key to a macro.[8] These edit macros evolved into Emacs.[8]
Example session
Given a file named hello.c with the following contents:
int main(int argc, char **argv)
{
printf("Hello world!\n");
return 0;
}
one could use the following TECO session (noting that the prompt is "*" and "$" is how ESC is echoed) to change "Hello" into "Goodbye":
*EBhello.c$$ Open file for read/write with backup
*P$$ Read in the first page
*SHello$0TT$$ Search for "Hello" and print the line (pointer placed after searched string)
printf("Hello world!\n"); The line
*-5DIGoodbye$0TT$$ Delete five characters before pointer (ie "Hello"), insert "Goodbye", and print the line
printf("Goodbye world!\n"); The updated line
*EX$$ Copy the remainder of the file and exit
Example code
Code sample | Explanation |
---|---|
ER file $ | open file for read access |
[q ... ]q | push ... pop register Q (can hold number, text, or code) |
< code > | iteration; there are codes for next, break, continue, etc. |
n "X then-code | else-code ' | if-then-else (X is a test type) |
As a programming language
The obscurity of the TECO programming language is well-described in the following quote from "Real Programmers Don't Use Pascal", a letter from Ed Post to Datamation, July 1983:
It has been observed that a TECO command sequence more closely resembles transmission line noise than readable text. One of the more entertaining games to play with TECO is to type your name in as a command line and try to guess what it does. Just about any possible typing error while talking with TECO will probably destroy your program, or even worse - introduce subtle and mysterious bugs in a once working subroutine.[9]
According to Craig Finseth, author of The Craft of Text Editing,[10] TECO could be considered to be one of the first "write-only" languages. That is, it could be argued that once a program is written in TECO, it would be extremely difficult to comprehend what it did without appropriate documentation.
Despite the odd syntax, the TECO command language was tremendously powerful, and clones are still available for MS-DOS and for Unix.
TECO commands are characters (including control-characters), and the prompt is a single asterisk:
*
The escape key displays as a dollar sign, pressed once it delineates the end of a command requiring an argument and pressed twice initiates the execution of the entered command(s):
*$$
Example programs
The first two examples are a simple interchange sort of the current text buffer, based on the 1st character of each line, taken from the PDP-11 TECO User's Guide. A "goto" and "structured" version are shown. Note that TECO ignores case and whitespace (except tab, which is an insertion command).
Example 1
!START! j 0aua ! jump to beginning, load 1st char in register A ! !CONT! l 0aub ! load first char of next line in register B ! qa-qb"g xa k -l ga 1uz ' ! if A>B, switch lines and set flag in register Z ! qbua ! load B into A ! l z-."g -l @o/CONT/ ' ! loop back if another line in buffer ! qz"g 0uz @o/START/ ' ! repeat if a switch was made on last pass !
Example 2
0uz ! clear repeat flag ! <j 0aua l ! load 1st char into register A ! <0aub ! load 1st char of next line into B ! qa-qb"g xa k -l ga -1uz ' ! if A>B, switch lines and set flag ! qbua ! load B into A ! l .-z;> ! loop back if another line in buffer ! qz;> ! repeat if a switch was made last pass !
Example 3
This example is a Brainfuck interpreter for TECO. It works by executing the buffer as a Brainfuck program, and demonstrates the capabilities of the editor.
@^UB#@S/{^EQQ,/#@^UC#@S/,^EQQ}/@-1S/{/#@^UR#.U1ZJQZ\^SC.,.+-^SXQ-^SDQ1J#@^U9/[]-+<>.,/<@:-FD/^N^EG9/;>J30000<0@I/
/>ZJZUL30000J0U10U20U30U60U7@^U4/[]/@^U5#<@:S/^EG4/U7Q7;-AU3(Q3-91)"=%1|Q1"=.U6ZJ@i/{/Q2\@i/,/Q6\@i/}/Q6J0;'-1%1'
>#<@:S/[/UT.U210^T13^TQT;QT"NM5Q2J'>0UP30000J.US.UI<(0A-43)"=QPJ0AUTDQT+1@I//QIJ@O/end/'(0A-45)"=QPJ0AUTDQT-1@I//
QIJ@O/end/'(0A-60)"=QP-1UP@O/end/'(0A-62)"=QP+1UP@O/end/'(0A-46)"=-.+QPA^T(-.+QPA-10)"=13^T'@O/end/'(0A-44)"=^TUT
8^TQPJDQT@I//QIJ@O/end/'(0A-91)"=-.+QPA"=QI+1UZQLJMRMB\-1J.UI'@O/end/'(0A-93)"=-.+QPA"NQI+1UZQLJMRMC\-1J.UI'@O/en
d/'!end!QI+1UI(.-Z)"=.=@^a/END/^c^c'C>
Example 4
This example calculates pi to an arbitrary number of digits.
GZ0J\UNQN"E 40UN ' BUH BUV HK QN< J BUQ QN*10/3UI QI< \+2*10+(QQ*QI)UA B L K QI*2-1UJ QA/QJUQ QA-(QQ*QJ)-2\ 10@I// -1%I > QQ/10UT QH+QT+48UW QW-58"E 48UW %V ' QV"N QV^T ' QWUV QQ-(QT*10)UH > QV^T @^A/ /HKEX$$
See also
Notes
- ↑ "TECO". The Jargon File. v.4.4.7. ibiblio.
- ↑ "EDIT/TECO". HP OpenVMS system documentation. Hewlett-Packard.
- ↑ "Summary of TECO commands". From a collection of MIT PDP-1 paper tapes at the Computer History Museum. Retrieved 2007-09-12.
- ↑ Murphy, Dan (2009). "The Beginnings of TECO" (PDF). IEEE Annals of the History of Computing 31 (4): 110–115.
- ↑ Samson, Peter (July 23, 1965). "PDP-6 TECO" (PDF). Memorandum MAC-M-250: 9. Retrieved 2007-09-12.
- ↑ Edwards, Daniel J. (October 29, 1964). "TECO 6". Memorandum MAC-M-191: 2. Archived from the original on 2007-09-28. Retrieved 2007-09-12.
- ↑ "For the Time Sharing Computer User: Datapoint 3300" (PDF). Computer Terminal Corporation. Retrieved 2009-10-27.
- 1 2 "Teco Editor". c2.com. August 16, 2010. Retrieved 2013-08-17.
- ↑ Post, Ed (July 1983). "Real Programmers Don't Use PASCAL". Datamation 29 (7): 263–265.
- ↑ Finseth, Craig A. (2006). The Craft of Text Editing. Lulu.com. ISBN 978-1-4116-8297-9.
References
- TECO pocket guide. Digital Equipment Corporation. 1978. Archived from the original on 2008-06-21. Retrieved 2012-05-24.
- Murphy, Dan (2009). "The Beginnings of TECO" (PDF). IEEE Annals of the History of Computing 31 (4): 110–115.
External links
- Dan Murphy's personal site
- Pete Siemsen's TECO collection
- Tom Almy's TECO page. Includes a TECO based on Pete Siemsen's TECOC and DECUS documentation. There are MS-DOS, Windows (console), Linux, Mac OS X, and OS/2 versions.
- Introduction to the TECO syntax
- TECO Information
This article is based in part on the Jargon File, which is in the public domain.