The Full Wiki

Vi: Wikis

  

Note: Many of our articles have direct quotes from sources you can cite, within the Wikipedia article! This article doesn't yet, but we're working on it! See more info or our list of citable articles.

Encyclopedia

(Redirected to vi article)

From Wikipedia, the free encyclopedia

vi
Vi-splash.png
vi editing a temporary, empty file. Tildes signify lines not present in the file.
Developer(s) 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 certain 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 "six" as in the Roman numeral VI.[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

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. 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 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 c wreplacement text Escape 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.

EX commands in vi

Ex is a line editor that serves as the foundation for the screen editor vi. Ex commands work on the current line or on a range of lines in a file.

Syntax of Ex commands
:[address] command [options]

':' specifies an Ex command.

Address
The 'address' specifies the lines number or range of lines that are the object of command.If no address is given,the current line is the object of the command.

Address Ranges can be specified by any of the following ways in Ex command syntax.

Syntax Range
 :% All the lines in the file.
:1,$ All the lines in the file.
:^,$ All the lines in the file.
:X,Y All the lines between Line number X to Line number Y.
:.,.+n All the lines between current line and next n lines.
:.,.-n All the lines between current line and previous n lines.
:X;Y Line number X to Line number Y with current line set as Line Number X.
:X,+n All the lines between Line number X and next n lines from Current Line.
:X,-n All the lines between Line number X and previous n lines from Current Line.
:X The Line number X.
:. The Current Line.
:$ The Last line of File.
:0 The First line of file
:X-n The Line which is n lines before Line number X .
:X+n The Line which is n lines after Line number X .
:'b The Line which is marked by letter b.
:' The Line which is marked.
:/word Next Line containing pattern word
:?word Previous Line containing pattern word

Commands

Command Ex Syntax Operation
Substitute :%s/str1/str2/g Substitute str1 by str2 in the Address range specified as whole file.
Copy and Paste :t8 Copy current line and Paste after Line number 8.
Copy and Paste :9t11 Copy line 9 and Paste after Line number 11.
Copy and Paste :5,8t10 copy lines 5 through 8 and Paste after Line number 10.
Copy and Paste :10,14co20 Copy lines 10 through 14 and Paste after Line number 20.
Move and Paste :m8 Cut current line and Paste after Line number 8.
Move and Paste :9m11 Cut line 9 and Paste after Line number 11.
Move and Paste :5,8m10 Cut lines 5 through 8 and Paste after Line number 5.
Yank/Copy in named buffer. :3,10y p Copy the text between line number 3 and line number 10 in a buffer p (single lowercase char)
Yank/Copy. :3,10y Copy the text between line number 3 and line number 10 in a temporary buffer.
Paste/Put :10p Paste the text in temporary buffer at line number 10.
Paste/Put :p Paste the text in temporary buffer at Current line .
Paste/Put :+10p Paste the text in temporary buffer at 10 lines after Current line
Write/Save file :w! Save the current file.
Write/Save file :w fname Save the current file as fname. Similar to "Save as" in Windows Operating system.
Write/Save file :15,30w fnew Saves the Lines between Line number 15 to Line number 30 of current file in a new file named fnew.
Write/Save file :15,30w >> fexist appends the Lines between Line number 15 to Line number 30 of current file in a file named fexist.
Write/Save file :x! Save & Quit current file Forcefully.
Quit file :q Quit the current file.
Quit file :q! Quit current file Forcefully without saving.
Edit/Refresh :e! Refresh- Discard changes not saved.
Edit :e fname Edit file named fname without leaving vi.
Edit :n Edit next file without leaving vi.
Edit :p Edit previous file without leaving vi.
Edit :rew Edit previous file without leaving vi.
Insert file :r fname Inserts all the text in the file named "fname" at the current cursor location.
Read/Insert :r! command Inserts the output of command at the current cursor location.
read/Insert 10:r! command Inserts the output of command at Line number 10.
Insert file  :r fname Inserts all the text in the file named "fname" at the current cursor location.
Insert text :45i! Sets up insert mode at Line number 45.
append text :45a! Sets up append mode at Line number 45.
Delete Lines :d Deletes current line.
Delete Line :45d Delete Line number 45.
Delete Lines :.,.+15d Delete all the lines between current line and next 15 lines
Delete Lines and put in buffer :.,.+15d f Delete all the lines between current line and next 15 lines and put them in a buffer named f
mark a Line :10ma f Mark the Line number 10 with a single lowercase char f.Return later to the mark by 'f.
Shell Command 10,15:! command Execute command in a shell. Treat the text between Line number 10 and Line number 15 as standard input to command, and replace these lines with the output.
View :10z Set up a view with Line number 10 at the Top of screen.
View :10z+ Set up a view with Line number 10 at the Top of screen.
View :10z- Set up a view with Line number 10 at the bottom of screen.
View :100z. Set up a view with Line number 100 at the center of screen.
View :100z^ Set up a view with Line number 100 at the center of screen and set current line as Line number 100.
View :10z+ 5 Set up a view with Line number 10 at the Top of screen and display next 5 lines from Line number 10.
Status :f Shows current position and the file name at the bottom of the screen.It also specifies if any changes are made to the file since it has been opened.

Options

Option Operation
 ! Specifies the command has to be executed forcefully.
destination Specifies the Line number where the text is to be pasted.Used with Copy and Move commands.
count Specifies the number of time command is to be repeated.This number always succeed the command.
fname Specifies that the object is a file name "fname".

Customize vi editor

ex command operation
:set showmode Show when you are in insert mode.
:set ic Ignore case when searching
:set noic Turn ignore case off
:set nu Turn on line numbering
:set nonu Turn line numbering off (set nonumber)
:set all List settings of all options.
:set ai Set autoindent.Facilitates structured insertion of text.
:set noai Prevent the autoindent.
:set wrapmargin=2 Set margin for insertion of new line in input mode as 2.
:set autoprint Display the current line after execution of ex copy, move, or substitute command.
:set window=40 set the number of lines in a vi window as 40.
:set scroll=11 set the number of lines scrolled in a vi window as 11 when <Ctrl> D is pressed.

History

ADM3A keyboard layout

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 "extended" 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, 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, Mark Horton took on responsibility for vi. Horton added support for arrow and function keys, macros, and improved performance by replacing termcap with terminfo. In 1983, 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]

Derivatives and clones

The startup screen of vi clone vim
  • 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. Vim is included with almost every Linux distribution (and is also shipped with every copy of Apple Mac OS X). 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.
  • BusyBox, a set of standard Linux utilities in a single executable, includes a tiny vi clone.

Plugins for other applications that emulate vi

See also

References

  1. ^ The Open Group (1997), "vi - screen-oriented (visual) display editor", Single Unix Specification, Version 2, http://opengroup.org/onlinepubs/007908799/xcu/vi.html, retrieved 2009-01-25  
  2. ^ Bolsky, M. I. (1984). The vi User's Handbook. AT&T Bell Laboratories. ISBN 1-394-1733-8.  
  3. ^ 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.  
  4. ^ Gross, Christian (2005). Open Source for Windows Administrators. Charles River Media. pp. 55. ISBN 1-584-50347-5.  
  5. ^ Thomer M Gil, Vi Lovers Home Page, http://thomer.com/vi/vi.html, retrieved 2009-01-24  
  6. ^ 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 2008-12-05.  
  7. ^ "Ask Tim Archive". O'Reilly. June 21, 1999. http://www.oreilly.com/pub/a/oreilly/ask_tim/1999/unix_editor.html.  
  8. ^ "Vim documentation: options". vim.net/sourceforge.net. http://vimdoc.sourceforge.net/htmldoc/options.html#'compatible'. Retrieved January 30, 2009.  
  9. ^ "Vim documentation: starting". vim.net/sourceforge.net. http://vimdoc.sourceforge.net/htmldoc/starting.html#compatible-default. Retrieved January 30, 2009.  
  10. ^ "TextEditors Wiki: ViFamily". http://texteditors.org/cgi-bin/wiki.pl?ViFamily. Retrieved 2009-06-22.  
  11. ^ "ViperMode". http://www.emacswiki.org/emacs/ViperMode. Retrieved 2009-06-23.  

Further reading

External links


1911 encyclopedia

Up to date as of January 14, 2010

From LoveToKnow 1911

VI. (d. 1362). The church and other remains of the Carthusian monastery of Val-de-Benediction, founded in 1356 by Innocent VI., are now used for habitation and other secular purposes. A gateway and a rotunda, built as shelter for a fountain, both dating from about 1670, are of architectural note. On the Mont Andaon, a hill to the north-east of the town, stands the Fort of St Andre (14th century), which is entered by an imposing fortified gateway and contains a Romanesque chapel and remains of the abbey of St Andre. The other buildings of interest include several old mansions once belonging to cardinals and nobles, and a tower, the Tour de Philippe le Bel, built in the 14th century, which guarded the western extremity of the Pont St Benezet (see Avignon).

In the 6th century the Benedictine abbey of St Andre was founded on Mount Andaon, and the village which grew up round it took its name. In the 13th century the monks, acting in concert with the crown, established a bastide, or "new town," which came to be called Villeneuve. The town was the resort of the French cardinals during the sojourn of the popes at Avignon, and its importance, due largely to its numerous religious establishments, did not decline till the Revolution.


<< Villeneuve-Les-Avignon

Villeneuve-Sur-Lot >>


Wiktionary

Up to date as of January 15, 2010

Definition from Wiktionary, a free dictionary

See also vi, and VI

English

Proper noun

Singular
Vi

Plural
-

Vi

  1. Short form of Violet and Viola.

Anagrams

  • Anagrams of IV

Wikibooks

Up to date as of January 23, 2010
(Redirected to Learning the vi editor article)

From Wikibooks, the open-content textbooks collection

This book aims to teach you how to use the vi
editor, common to many Unix and Unix-like operating systems.
~
~
~
~
~
"Learning_the_vi_editor" [New file].

The above text is a little example of how the vi editor's screen looks.

Contents

Other sources of information:

Acknowledgments Development stage: 100% (as of Jan 11, 2005)








Got something to say? Make a comment.
Your name
Your email address
Message