Introduction to Vi in Dedicated Hosting

December 28, 2009

In the beginning, UNIX had only one editor, the line editor "ed." UNIX still has ed, but few people use it. Line-by-line editors really are adequate only for making short, quick corrections to files or programs. A medieval version of UNIX contained a new program called "ex." The most notable new feature of ex was a display editing facility which allowed a user to work with a full screen of text by giving the command vi . The new display editor proved so popular that AT&T UNIX System V included "vi" as a separate program. Vi is included in most operating systems.

This handout explains the basics of vi: creating files, moving the cursor and entering and editing text. After you have read it and practiced for a short time at your console, you should be able to do basic editing with vi. If you wish to use some of vi’s more complicated resources, we recommend a close study of the man pages.

Modes
You will encounter three different editing modes when you use vi: command, input and last line.

Command Mode
When you call vi with a command line such as

Code:

darkstar% vi editfile

you are automatically placed in Command mode. While in Command mode you can move your cursor around on the screen, view different parts of the file, delete text and carry out searches.

Input Mode

To enter text while in vi, you need to be in Input mode. You may enter Input mode by using any of five different commands: insert (i), append (a), open (o), change (c) or replace (r). To return from any Input mode to Command mode, press the escape key.

The insert command, i , puts vi in Input mode and places text before the current character.

The append command, a , puts vi in Input mode and places text after the current character. (A places text after the last character on the current line).

The open commands, o and O , open a blank line within existing text, put the cursor at the beginning of that line and put vi into Input mode. o opens a line below the current line, O opens a line above the current line.

Watch for Part 2, Coming Soon!

More Dedicated Web Hosting Help!

Comments are closed.