Line editor

In computing, a line editor is a text editor in which each editing command applies to one or more complete lines of text designated by the user. Line editors predate screen-based text editors and originated in an era when a computer operator typically interacted with a teleprinter (essentially a printer with a keyboard), with no video display, and no ability to move a cursor interactively within a document. Line editors were also a feature of many home computers, avoiding the need for a more memory-intensive full-screen editor.

Line editors are limited to typewriter keyboard text-oriented input and output methods. Most edits are a line-at-a-time. Typing, editing, and document display do not occur simultaneously. Typically, typing does not enter text directly into the document. Instead, users modify the document text by entering these commands on a text-only terminal. Commands and text, and corresponding output from the editor, will scroll up from the bottom of the screen in the order that they are entered or printed to the screen. Although the commands typically indicate the line(s) they modify, displaying the edited text within the context of larger portions of the document requires a separate command.

Line editors keep a reference to the 'current line' to which the entered commands usually are applied. In contrast, modern screen based editors allow the user to interactively and directly navigate, select, and modify portions of the document. Generally line numbers or a search based context (especially when making changes within lines) are used to specify which part of the document is to be edited or displayed.

Early line editors included Colossal Typewriter, Expensive Typewriter and QED. All three pre-dated the advent of UNIX; the former two ran on DEC PDP-1's, while the latter was a Unisys product. Numerous line editors are included with UNIX and GNU/Linux: ed is considered the standard UNIX editor, while ex extends it and has more features, and sed was written for pattern-based text editing as part of a shell script. GNU Readline is a line editor implemented as a library that is incorporated in many programs, such as Bash. For the first 10 years of the IBM PC, the only editor provided in DOS was the Edlin line editor.

Line editors are still used non-interactively in shell scripts, and TECO (see below) can be used in much the same manner, albeit with more features. Patch systems such as patch (Unix) traditionally used diff data that was a script of ed commands. They are also used in many MUD systems, though many people prefer to edit text on their own computer and then use their MUD client's upload feature to paste the text directly in the line editor.

TECO

While TECO is sometimes incorrectly considered a line editor, it is in fact modal and character-oriented. In non-technical terms, it's perhaps best described as a modern editor in the tradition of Vim running with the document out of view. Line commands are understood as searching for the two-character string "[CR][LF]", and the insertion point may in fact be positioned between these two characters. Because the PDP-6 used a modified IBM Selectric as a printer, and because the Selectric used physical movements of the platen and carriage to print text, boldface, strikethrough, and underscore were all possible by omitting either the [CR] or [LF]. Below is an example of TECO showcasing special text effects and its character-oriented nature; note that the asterisk is TECO's input prompt, and dollar signs stand for a press of the Escape key.

*0jht$$
The PDP-6, in combination with the IBM Selectric and a full-featured 
editor like TECO, can produce a wide variety of text effects.  The 
user can underscore text by deleting the line feed at the end of the 
line requiring underscoring, spacing up to the beginning of the text 
being underscored, then inserting underscore characters.  Alternative 
underscoring can be produced with circumflex characters.

Boldface is produced by removing the carriage return, keeping the line 
feed, and repeating the text to be bolded.  It is important to note 
that boldface and underscore can not be used on the same line of text.
*sunderscore$0ttl$$
user can underscore text by deleting the line feed at the end of the 
 text by deleting the line feed at the end of the
*-d0tt$$
user can underscore text by deleting the line feed at the end of the [CR]line requiring underscoring, spacing up to the beginning of the text 
line requiring underscoring, spacing up to the beginning of the text
*9<i $>10<i_$>i[ENTER]$-tl-dt$$
user can underscore text by deleting the line feed at the end of the [CR]         _________
line requiring underscoring, spacing up to the beginning of the text [CR] being underscored, then inserting underscore characters.  Alternative 
(remainder of editing session omitted for brevity)
*zjk$$
ERROR: Invalid range specified for K

Superficially, this looks much like a line editor session; it is important, however, to note that the next-line command (l) actually means move to position following next consecutive CR LF, that this position is the number of characters from the start of the file, and that if the user knew the position, he could manually jump to it with the jump (j) command.

The last two commands issued (zj and k) are shorthand for "jump to final position" and "kill line". They, or their direct equivalents, are useful to disambiguate between a line editor and a character-oriented editor. On a line editor, these would have the expected effect, i.e. that of deleting the final line of the file. On TECO, the command fails, because it sees a line as "a string of text terminated by consecutive CR LF"; in its eyes, the "last" line would in fact be the penultimate.

Emacs grew out of an effort by Richard M. Stallman to produce a standard set of macros for the Massachusetts Institute of Technology, which was then using a later version of TECO that was in fact screen-oriented. This was later re-written by others for portability. TECO and Emacs now share little in common; screen-oriented TECO, which still exists as Video TECO and SciTECO, is in fact closer to Vim in user experience.

See also

led, another line-oriented text editor

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.