name = Vi
caption = vi editing a temporary, empty file. Tildes signify lines not present in the file.
vi is a screen-oriented
text editorwritten by Bill Joyin 1976for 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 editorex to visual mode. The name vi is pronEng|ˈviːˈaɪ, cite book | last = Raymond | first = Eric S | coauthors = Guy L. Steele, Eric S. Raymond | authorlink = Eric S. Raymond | editor = (ed.) | year = 1996 | title = The New Hacker's Dictionary | publisher = MIT Press | edition = 3rd edition | id = ISBN 0-262-68092-0 ] or IPA|/vaɪ/. [cite book | last = Gross | first = Christian | year = 2005 | title = Open Source for Windows Administrators | publisher = Charles River Media | id = ISBN 1-584-50347-5 | pages = p. 55 ]
Current releases of vi are
free and open source software, usually released under permissive free software licenses such as the BSD License.
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 keyswitches the editor back to normal mode.)
vi can process compound commands that embed text for insertion in the document. For example, the command:
20iHello world! "
" " "
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. 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. Fact|date=January 2008
Bill Joywrote vi at the University of California, Berkeley, on a Lear-Siegler ADM3Aterminal. On this terminal, the Escape key was on the left, where the Tab key is now on the widely-used IBM PC keyboard, thus enabling users to very efficiently switch modes. Also, the keys "h","j","k","l" had arrows, explaining the usage of these keys for moving around. The ADM3A had no other keys that corresponded to arrows.
vi became the "
de facto" standard Unixeditor and a nearly undisputed hacker favorite outside of MIT until the rise of Emacsafter about 1984. As of 2008either vi or one of its clones can still be found on nearly all installations of Unix. The Single UNIX Specificationspecifies vi, so any system conforming to the Single UNIX Specification will have vi.
vi is still widely used by users of Unix variants. About half the respondents in a
1991USENET poll preferred vi. It starts up faster than the bulkier versions of Emacs and uses less memory. Consequently, even some Emacs fans will resort to it as a mail editor and for small editing jobs. In 1999, Tim O'Reilly, founder of the eponymous computer book publisher, stated that his company sold more copies of its vi book than its emacs book. [ cite web | url = http://www.oreilly.com/pub/a/oreilly/ask_tim/1999/unix_editor.html | title = Ask Tim Archive | publisher = O'Reilly | date = Jun 21 1999 ]
Upon start-up, vi starts in normal mode (unless instructed otherwise). Typing the letter 'i' (without quotes) enters insert mode. Any text typed thence gets added to the document, until the escape key is pressed, at which point the insert mode is exited and vi switches to normal mode. (There are few more commands that switch the editor into insert mode, but they differ only in where the new text will go - before the cursor, after the cursor, above current line, below current line, etc.).
There are two main classes of commands: cursor movements and text modification. Vi is the fullscreen counterpart to ex, and cursor movement is a key part of the design.
; MotionsThese commands move the cursor, either relative to its current position, or to an absolute position.
Relative motions can be prefixed with a count, to tell vi to repeat the motion. These are relative motion commands:
In some instances, if the motion command repeats the operator character (as in 'dd'), the region is a whole line. Thus "dd" deletes the current line, and "cc"new"
" replaces the entire current line with the text 'new'. Prefixing it with a count repeats (or makes it apply to more than one), e.g., "10dd" deletes 10 lines.
; Inline CommandsA few commands move the cursor only within the current line. Like operators, they accept a repeat count:
Where applicable, these commands take a line number or a range of line numbers. E.g., "10,25w "newfile" will write lines 10 through 25 (inclusive) into the file "newfile"; "$r "newfile" will read the contents of file "newfile" after the last line of the current document ('$' stands for the last line).
; Maps and abbreviationsA frequently used command sequence can be mapped to a new command-letter. The sequence could even include any text to be inserted. E.g.,:
:map * iAuthor: John Bullcauses the '*' character to be a command that inserts "Author: John Bull" at the cursor position.
An abbreviation is like a mapping, but during insert mode. Example:
:abbr US United StatesThis will insert "United States" whenever the word "US" is typed when in insert mode.
Derivatives and clones
nviis 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 and many new editing commands. It is the standard version of vi on most Linuxsystems.
* Elvis is a free vi clone for Unix and other operating systems. This is the standard version of vi shipped on
Slackware Linuxand Kate OS.
* vile was initially derived from an early version of
Microemacsin an attempt to bring the Emacsmulti-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.
List of text editors
Comparison of text editors
List of Unix programs
* Oualline, Steve (2001) " [http://www.truth.sk/vim/vimbook-OPL.pdf Vi IMproved - Vim] ", New Riders Publishers, 572 pp.
* [http://ex-vi.sourceforge.net/ The original Vi version, adapted to more modern standards]
* [http://docs.freebsd.org/44doc/usd/12.vi/paper.html An Introduction to Display Editing with Vi] , by Mark Horton and vi programmer Bill Joy
* [http://www.thomer.com/vi/vi.html vi lovers home page]
* [http://www.saki.com.au/mirror/vi/ The vi Editor and its clones and programs with a vi like interface]
* [http://www.theregister.co.uk/2003/09/11/bill_joys_greatest_gift/ "Bill Joy's greatest gift to man – the vi editor,"] from "
* [http://www.viemu.com/a-why-vi-vim.html explanation of modal editing with vi -- "Why, oh WHY, do those #?@! nutheads use vi?"]
Wikimedia Foundation. 2010.