Vi (text editor)
vi (pronounced as distinct letters, /ˌviːˈaɪ/ ⓘ)[1] is a screen-oriented text editor originally created for the Unix operating system. The portable subset of the behavior of vi and programs based on it, and the ex editor language supported within these programs, is described by (and thus standardized by) the Single Unix Specification and POSIX.[2] The original code for vi was written by Bill Joy in 1976 as the visual mode for the ex line editor that Joy had written with Chuck Haley.[3] Joy's ex 1.1 was released as part of the first Berkeley Software Distribution (BSD) Unix release in March 1978. It was not until version 2.0 of ex, released as part of Second BSD in May 1979 that the editor was installed under the name "vi" (which took users straight into ex's visual mode),[4] and the name by which it is known today. Some current implementations of vi can trace their source code ancestry to Bill Joy; others are completely new, largely compatible reimplementations.[citation needed][discuss] The name "vi" is derived from the shortest unambiguous abbreviation for the ex command visual, which switches the ex line editor to its full-screen mode. The name is pronounced /ˌviːˈaɪ/ (the English letters v and i).[5][6] In addition to various non–free software variants of vi distributed with proprietary implementations of Unix, vi was opensourced with OpenSolaris, and several free and open source software vi clones exist. A 2009 survey of Linux Journal readers found that vi was the most widely used text editor among respondents, beating gedit, the second most widely used editor, by nearly a factor of two (36% to 19%).[7] HistoryCreationvi was derived from a sequence of UNIX command line editors, starting with ed, which was a line editor designed to work well on teleprinters, rather than display terminals. Within AT&T Corporation, where ed originated, people seemed to be happy with an editor as basic and unfriendly as ed, George Coulouris recalls:[8]
Coulouris considered the cryptic commands of ed to be only suitable for "immortals", and thus in February 1976, he enhanced ed (using Ken Thompson's ed source as a starting point) to make em (the "editor for mortals"[9]) while acting as a lecturer at Queen Mary College.[8] The em editor was designed for display terminals and was a single-line-at-a-time visual editor. It was one of the first programs on Unix to make heavy use of "raw terminal input mode", in which the running program, rather than the terminal device driver, handled all keystrokes. When Coulouris visited UC Berkeley in the summer of 1976, he brought a DECtape containing em, and showed the editor to various people. Some people considered this new kind of editor to be a potential resource hog, but others, including Bill Joy, were impressed.[8] Inspired by em, and by their own tweaks to ed,[3] Bill Joy and Chuck Haley, both graduate students at UC Berkeley, took code from em to make en,[3][10] and then "extended" en to create ex version 0.1.[3] After Haley's departure, Bruce Englar encouraged Joy to redesign the editor,[11] which he did June through October 1977 adding a full-screen visual mode to ex[12]—which came to be vi.[13] vi and ex share their code; vi is the ex binary launching with the capability to render the text being edited onto a computer terminal—it is ex's visual mode.[13] The name vi comes from the abbreviated ex command ( According to Joy, many of the ideas in this visual mode were taken from Bravo—the bimodal text editor developed at Xerox PARC for the Alto. In an interview about vi's origins, Joy said:[3]
Joy used a Lear Siegler ADM-3A terminal. On this terminal, the Escape key was at the location now occupied by the Tab key on the widely used IBM PC keyboard (on the left side of the alphabetic part of the keyboard, one row above the middle row). This made it a convenient choice for switching vi modes. Also, the keys h,j,k,l served double duty as cursor movement keys and were inscribed with arrows, which is why vi uses them in that way. The ADM-3A had no other cursor keys. Joy explained that the terse, single character commands and the ability to type ahead of the display were a result of the slow 300 baud modem he used when developing the software and that he wanted to be productive when the screen was painting slower than he could think.[10] DistributionJoy was responsible for creating the first BSD Unix release in March, 1978, and included ex 1.1 (dated 1 February 1978)[15] in the distribution, thereby exposing his editor to an audience beyond UC Berkeley.[16] From that release of BSD Unix onward, the only editors that came with the Unix system were ed and ex. In a 1984 interview, Joy attributed much of the success of vi to the fact that it was bundled for free, whereas other editors, such as Emacs, could cost hundreds of dollars.[3] Eventually it was observed that most ex users were spending all their time in visual mode,[citation needed] and thus in ex 2.0 (released as part of Second Berkeley Software Distribution in May, 1979), Joy created vi as a hard link to ex,[17] such that when invoked as vi, ex would automatically start up in its visual mode. Thus, vi is not the evolution of ex, vi is ex. Joy described ex 2.0 (vi) as a very large program, barely able to fit in the memory of a PDP-11/70,[18] thus although vi may be regarded as a small, lightweight program today, it was not seen that way early in its history. By version 3.1, shipped with 3BSD in December 1979, the full version of vi was no longer able to fit in the memory of a PDP-11;[19] the editor would be also too big to run on PC/IX for the IBM PC in 1984.[20] Joy continued to be lead developer for vi until version 2.7 in June 1979,[11][21] and made occasional contributions to vi's development until at least version 3.5 in August 1980.[21] In discussing the origins of vi and why he discontinued development, Joy said:[3]
In 1979,[3] Mary Ann Horton took on responsibility for vi. Horton added support for arrow and function keys, macros, and improved performance by replacing termcap with terminfo.[11][22] Ports and clonesUp to version 3.7 of vi, created in October 1981,[21] UC Berkeley was the development home for vi, but with Bill Joy's departure in early 1982 to join Sun Microsystems, and AT&T's UNIX System V (January 1983) adopting vi,[23] changes to the vi codebase happened more slowly and in a more dispersed and mutually incompatible way. At UC Berkeley, changes were made but the version number was never updated beyond 3.7. Commercial Unix vendors, such as Sun, HP, DEC, and IBM each received copies of the vi source, and their operating systems, Solaris, HP-UX, Tru64 UNIX, and AIX, continued to maintain versions of vi directly descended from the 3.7 release, but with added features such as adjustable key mappings, encryption, and wide character support. In 1983, vi was one of several UNIX tools available for Charles River Data Systems' UNOS operating system under Bell Laboratories license.[24] While commercial vendors could work with Bill Joy's codebase, many people could not. Because Joy had begun with Ken Thompson's ed editor, ex and vi were derivative works and could not be distributed except to people who had an AT&T source license.[citation needed] Those wanting a free Unix-style editor would have to look elsewhere. By 1985, a version of Emacs (MicroEMACS) was available for a variety of platforms, but it was not until June 1987 that STEVIE (ST Editor for VI Enthusiasts), a limited vi clone, appeared for the Atari ST.[25][26] In early January 1990, Steve Kirkendall posted a new clone of vi, Elvis, to the Usenet newsgroup comp.os.minix, aiming for a more complete and more faithful clone of vi than STEVIE.[27] It quickly attracted considerable interest in a number of enthusiast communities.[28] Andrew Tanenbaum quickly asked the community to decide on one of these two editors to be the vi clone in Minix;[29] Elvis was chosen, and remains the vi clone for Minix today. In 1989, Lynne Jolitz and William Jolitz began porting BSD Unix to run on 386 class processors, but to create a free distribution they needed to avoid any AT&T-contaminated code, including Joy's vi. To fill the void left by removing vi, their 1992 386BSD distribution adopted Elvis. 386BSD's descendants, FreeBSD and NetBSD, followed suit. But at UC Berkeley, Keith Bostic wanted a "bug for bug compatible" replacement for Joy's vi for 4.4BSD-Lite. Using Kirkendall's Elvis (version 1.8) as a starting point, Bostic created nvi, releasing it in the northern spring of 1994.[30] When FreeBSD and NetBSD resynchronized the 4.4-Lite2 codebase, they too switched over to Bostic's nvi, which they continue to use today.[30] Despite the existence of vi clones with enhanced feature sets, sometime before June 2000,[31] Gunnar Ritter ported Joy's vi codebase (taken from 2.11BSD, February 1992) to modern Unix-based operating systems, such as Linux and FreeBSD. Initially, his work was technically illegal to distribute without an AT&T source license, but, in January 2002, those licensing rules were relaxed,[32] allowing legal distribution as an open-source project. Ritter continued to make small enhancements to the vi codebase similar to those done by commercial Unix vendors still using Joy's codebase, including changes required by the POSIX.2 standard for vi. His work is available as Traditional Vi.[33] But although Joy's vi was now once again available for BSD Unix, it arrived after the various BSD flavors had committed themselves to nvi, which provided a number of enhancements over traditional vi, and dropped some of its legacy features (such as open mode for editing one line at a time). Thus BSD Unix, where Joy's vi codebase began, no longer uses it, and the AT&T-derived Unixes, which in the early days lacked Joy's editor, are the ones that now use and maintain modified versions of his code. ImpactOver the years since its creation, vi became the de facto standard Unix editor and a hacker favorite outside of MIT until the rise of Emacs after about 1984.[34] The Single UNIX Specification specifies vi, so every conforming system must have it. vi is still widely used by users of the Unix family of operating systems. About half the respondents in a 1991 USENET poll preferred vi.[35] In 1999, Tim O'Reilly, founder of the eponymous computer book publishing company, stated that his company sold more copies of its vi book than its Emacs book.[36] Interfacevi is a modal editor: it operates in either insert mode (where typed text becomes part of the document) or command mode (where keystrokes are interpreted as commands that control the edit session). For example, typing i while in command mode switches the editor to insert mode, but typing i again at this point places an "i" character in the document. From insert mode, pressing ESC switches the editor back to command mode. A perceived advantage of vi's separation of text entry and command modes is that both text editing and command operations can be performed without requiring the removal of the user's hands from the home row. As non-modal editors usually have to reserve all keys with letters and symbols for the printing of characters, any special commands for actions other than adding text to the buffer must be assigned to keys that do not produce characters, such as function keys, or combinations of modifier keys such as Ctrl, and Alt with regular keys. Vi has the property that most ordinary keys are connected to some kind of command for positioning, altering text, searching and so forth, either singly or in key combinations. Many commands can be touch typed without the use of Ctrl or Alt. Other types of editors generally require the user to move their hands from the home row when touch typing:
For instance, in vi, replacing a word is cwreplacement textEscape, which is a combination of two independent commands (change and word-motion) together with a transition into and out of insert mode. Text between the cursor position and the end of the word is overwritten by the replacement text. The operation can be repeated at some other location by typing ., the effect being that the word starting at that location will be replaced with the same replacement text. A human–computer interaction textbook notes on its first page that "One of the classic UI foibles—told and re-told by HCI educators around the world—is the vi editor's lack of feedback when switching between modes. Many a user made the mistake of providing input while in command mode or entering a command while in input mode."[37] Contemporary derivatives and clones
See alsoReferences
Further reading
External linksWikibooks has more on the topic of: Vi (text editor)
|