![]() |
|||||||||||||
|
Vi |
vi editing a temporary, empty file. Tildes signify lines not present in the file. |
|
| Developed by | Bill Joy |
|---|---|
| Written in | C |
| OS | Unix-like |
| Type | text editor |
| License | BSD License |
vi is a screen-oriented text editor written by Bill Joy in 1976 for an early BSD release.
The name vi is derived from the shortest unambiguous abbreviation for the command visual in ex; the command in question switches the line editor ex to visual mode. The name vi is pronounced /ˈviːˈaɪ/,1 or /vaɪ/.2
Current releases of vi are free and open source software, usually released under permissive free software licenses such as the BSD License.
Contents |
vi is a modal editor: it operates in either insert mode (where typed text becomes part of the document) or normal mode (where keystrokes are interpreted as commands that control the edit session). Typing i while in normal mode switches the editor to insert mode. Typing i again at this point places an "i" character in the document. How the i keystroke is processed depends on the editor mode. From insert mode, pressing the escape key switches the editor back to normal mode.
vi can process compound commands that embed text for insertion in the document. For example, the command:
would insert 20 lines in the document with the text Hello world!. Rather than grapple with the notion of two mode switches while executing this command, some users view vi as a stateful filter.citation needed After processing the third character, vi changes state and begins processing input as text to be added to the file. On processing the escape, vi returns to the state in which it is ready to receive a new command.
Whether viewed as modal or stateful, vi's processing of the same keystroke in different ways depending on the history of the edit session distinguishes it from editors which are generally considered non-modal.
A perceived advantage of a modal editor is that the use of keyboard chords (multiple keys pressed simultaneously, typically a modifier plus a letter key) is reduced or eliminated. Instead, in normal mode, single keystrokes serve as commands. This results in the user's hands not having to take up awkward positions, which some find results in faster work.citation needed
vi was derived from a sequence of UNIX command line editors, starting with ed. ed was enhanced to become em, then en.3 At the University of California, Berkeley, Bill Joy enhanced em to create ex, including the addition of a visual mode. Eventually it was observed that most ex users were spending all their time in visual mode,citation needed and Joy created a direct entry command called vi.
Joy used a Lear-Siegler ADM3A 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 ADM3A had no other cursor keys.
In 1979,citation needed Mark Horton took on responsibility for vi.citation needed Horton added support for arrow and function keys, macros,{cn}} and improved performance by replacing termcap with terminfo. In 1983,citation needed vi was added to Bell Labs System V and has not significantly changed since.
vi became the de facto standard Unix editor and a nearly undisputed hacker favorite outside of MIT until the rise of Emacs after about 1984. 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.1 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.4. It should, however, be noted that in comparison to vi, Emacs comes with a more extensive help library and a built-in tutorial.
| Wikibooks has more on the topic of |