Site hosted by Build your free website today!
Basic XHTML Adv XHTML DHTML Macromedia Op Sys Help



Vi (rhymes with “pie”) is a visual editor that’s been around for many years. It was born in 1974 with the original BSD version of Unix. Since then, vi has changed considerably, but still retains much of its origins.

Vi is a full-screen text editor. It is very powerful and includes a couple hundred functions and commands. In this class, though, we will only use vi to create and save simple text files.

It is fair to mention that vi is, generally, very confusing and hard to use for most students. Remember, vi is not a “What You See Is What You Get” type of editor - like Word For Windows. Vi was born in the days when computer users were usually geeks who communicated with a computer using a Teletype machine. Vi does not have any capability to print italics or boldfaced text. Vi does not format indented quotations or bulleted lists. Vi is, to put it briefly, but a simple text processor.

Why, then, use vi? There are other word processors available for Linux - some just as powerful as Word (Word Perfect and Sun Office come to mind). Vi is a simple, quick text processor that does not add extra formatting code (like tab stops) into a file. For programmers, vi is perfect - it doesn’t mangle text that must be processed by a compiler. While you may have trouble adjusting to the world of vi; remember, it is still widely used for jobs where a “clean” text file is needed. It would be impossible to say how many Web pages and Perl scripts have been developed (and still are being developed) with vi.

In this tutorial I have included a lot of explanatory text along with commands for you to type in and try. To emphasize commands you should type in, I have used a special font (note - the following line is not an actual command - it is just an example of the type of font I used in this lab manual):

command attribute

When you see something printed with that special font, enter the command as part of your tutorial. Of course, I would also encourage you to try vi on your own: kick its tires, take it out for a spin around the block. The more time you spend with vi the easier it will be to use.

Note: vi is case sensitive. If you accidentally press the caps lock key, commands will no longer work the way you expect. If vi suddenly seems to be “acting funny,” check the caps lock key.

Starting vi

The most common way to start vi is with a file name specification. If you enter vi myfile.txt the vi editor will start and automatically load the file named myfile.txt. If myfile.txt does not exist, then vi will create a new, empty file with that name.

You also can start vi by just entering vi (with no file specified). If you do that, Linux will start vi with an empty document - then you must supply a name for the document the first time you save it.

Note: when vi opens a new, empty document all the lines in that document start with a tilde (“~”). The first time you see this it looks a bit weird, but those are just placeholders and has no effect on your file. When you save your file the tildes will go away.

For this tutorial, I prepared a file named vi.txt (you’ll find that file in the CIS 140 directory). Please open that file:

vi vi.txt

Your screen should look like Figure 1 if you opened the file correctly.

Note: the original vi editor was later improved and renamed to vim (for “vi improved”). Most Linux systems administrators actually use vim rather than vi – but have created an alias in the system so if a user enters the command vi the vim editor is what starts. When you look at the help files for vi you may notice that they talk about vim - don’t worry about that difference. This tutorial was written to match the system we use in class. (What we need now is for someone to create a new version of vim called super-vim (or svim). The logo, of course, would be a “svimming pool”. - Sorry about that, I couldn’t resist).

Figure 1 - Opening vi.txt

[Back To The Top Of This Page.]

© copyright 2003 | | page last updated: