vi
From Wikipedia, the free encyclopedia
vi editing a temporary, empty file. Tildes signify lines not present in the file. |
|
Developed by | Bill Joy |
---|---|
Written in | C |
Operating system | Unix-like |
Type | text editor |
License | BSD License |
vi is a family of screen-oriented text editors which share common characteristics, such as methods of invocation from the operating system command interpreter, and characteristic user interface features. The portable subset of the behavior of vi programs, and the ex editor language supported within these programs, is described by, and thus standardized by the Single Unix Specification[1] and POSIX.
The original vi program was written by Bill Joy in 1976 for an early BSD Unix release. Some current implementations of vi can trace their source code ancestry to Bill Joy; others are completely new, largely compatible reimplementations.
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ɪ/[2][3], or /vaɪ/[4], but never as /sɪks/[5].
Many popular implementations of vi are free and open source software, including some based on source code derived from Berkeley Unix. There are non-free implementations of vi, found in proprietary implementations of Unix.
Contents |
[edit] Interface
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.
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. Non-modal editors assign most of the keys that correspond to printable characters to commands which insert those characters into the buffer. Therefore, in these editors, any special commands for actions other than adding text to the buffer must be assigned to keys which don't produce characters, such as function keys, or combinations of modifier keys such as Ctrl, and Alt with regular keys. Vi has the advantage 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 ⇧ Shift, Ctrl or Alt.
Other types of editors generally require the user to move their hands from the home row when touch typing:
- To use a mouse to select text, commands, or menu items in a GUI editor.
- To the arrow keys or editing functions (Home / End or Function Keys).
- To invoke commands using modifier keys in conjunction with the standard typewriter keys.
The design of vi is based on considering the needs of users after they have become proficient, and who then require, from the software, efficiency and convenience rather than ease of learning. Another design assumption in vi is that inserting text is not the most important operation: people who maintain text files as part of their job need to be able to quickly move around in those files, and quickly make small, precise edits in different locations. The cost of transitions to insert mode is reduced by combining the mode switch with other commands. For instance, 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. It's also noteworthy that an operation like this is considered one indivisible command making a single logical change. Thus both the entry of the new text and the deletion of the word can be undone by typing u. Moreover, the operation can be repeated at some other location by typing ., the effect being that the word starting that location will be replaced with the same replacement text.
[edit] History
vi was derived from a sequence of UNIX command line editors, starting with ed. ed was enhanced to become em (the "editor for mortals" by George Coulouris while a lecturer at Queen Mary College), then en.[6] 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. 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.[6]
In 1979,[citation needed] Mark Horton took on responsibility for vi.[citation needed] Horton added support for arrow and function keys, macros,[citation needed] 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.[3] 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.[7].
[edit] Derivatives and clones
- nvi is an implementation of the ex/vi text editor originally distributed as part of the final official Berkeley Software Distribution(4.4BSD). This is the version of vi that is shipped with all BSD-based open source distributions. It adds command history and editing, filename completions, multiple edit buffers, multi-windowing (including multiple windows on the same edit buffer).
- Vim "Vi IMproved" has yet more features than vi, including (scriptable) syntax highlighting, mouse support, graphical versions, visual mode, many new editing commands and a large amount of extension in the area of ex commands. Many Linux distributions have chosen Vim as their implementation of vi. Vim also has a vi compatibility mode, controlled by the
:set compatible
[8] option. This mode is automatically turned on by Vim when it is started in a situation which looks as if the software might be expected to be vi compatible.[9]. Vim then changes some of its behaviors such that they are compatible with the vi standard. Vim features which do not conflict with vi compatibility are always available, regardless of the setting. - Elvis is a free vi clone for Unix and other operating systems. This is the standard version of vi shipped on Slackware Linux, Kate OS and MINIX.
- vile was initially derived from an early version of Microemacs in an attempt to bring the Emacs multi-window/multi-buffer editing paradigm to vi users.
- bvi "Binary VI" is an editor for binary files based on the vi text editor.
- BusyBox, a set of standard Linux utilities on a single executable, includes a tiny vi clone.
- Viper, an emacs package providing Vi emulation on top of Emacs.
- SlickEdit has a vi emulation mode since version 11.
[edit] See also
|
[edit] References
- ^ The Open Group (1997), "vi - screen-oriented (visual) display editor", Single Unix Specification, Version 2, http://opengroup.org/onlinepubs/007908799/xcu/vi.html, retrieved on 2009-01-25
- ^ Bolsky, M. I. (1984). The vi User's Handbook. AT&T Bell Laboratories. ISBN 1-394-1733-8.
- ^ a b Raymond, Eric S; Guy L. Steele, Eric S. Raymond (1996). (ed.). ed. The New Hacker's Dictionary (3rd edition ed.). MIT Press. ISBN 0-262-68092-0.
- ^ Gross, Christian (2005). Open Source for Windows Administrators. Charles River Media. pp. 55. ISBN 1-584-50347-5.
- ^ Thomer M Gil, Vi Lovers Home Page, http://thomer.com/vi/vi.html, retrieved on 2009-01-24
- ^ a b Vance, Ashlee (September 11, 2003). "Bill Joy's greatest gift to man – the vi editor". The Register. http://www.theregister.co.uk/2003/09/11/bill_joys_greatest_gift/. Retrieved on 2008-12-05.
- ^ "Ask Tim Archive". O'Reilly. June 21 1999. http://www.oreilly.com/pub/a/oreilly/ask_tim/1999/unix_editor.html.
- ^ "Vim documentation: options". vim.net/sourceforge.net. http://vimdoc.sourceforge.net/htmldoc/options.html#'compatible'. Retrieved on January 30, 2009.
- ^ "Vim documentation: starting". vim.net/sourceforge.net. http://vimdoc.sourceforge.net/htmldoc/starting.html#compatible-default. Retrieved on January 30, 2009.
[edit] Further reading
- Lamb, Linda; Arnold Robbins (1998). Learning the vi Editor (6th Edition). O'Reilly & Associates, Inc. http://www.oreilly.com/catalog/vi6/.
- Robbins, Arnold; Linda Lamb, Elbert Hannah (2008). Learning the vi and Vim Editors, Seventh Edition. O'Reilly & Associates, Inc. http://oreilly.com/catalog/9780596529833/.
[edit] External links
Wikibooks has more on the topic of |
- The original Vi version, adapted to more modern standards
- An Introduction to Display Editing with Vi, by Mark Horton and Bill Joy
- vi lovers home page
- "Bill Joy's greatest gift to man – the vi editor," from The Register
- explanation of modal editing with vi -- "Why, oh WHY, do those #?@! nutheads use vi?"
- vi Tutorial, Tips and Tricks
- VI keyboard shortcuts