Windows network administrators have long used Edit, Notepad, or Wordpad to edit large text and script files. Most UNIX systems have an editor of some sort; the actual utility varies depending on the flavor of UNIX you're running. Some, like Sun Microsystems, even have full-blown competitors to Microsoft Word. But, all UNIX machines have vithe visual editor. Once you know your way around vi, you can edit files on any flavor of UNIX, including Linux.
What's vi?
At first glance, vi appears to be anything but visual. It is, however, a very
powerful editor, and it can do anything you need. It allows you to edit and
see your entire document as you work. Many prior UNIX editors, such as ed, were
line-oriented editors, where you only saw one line of text at a time. So, vi
is considerably more visual than past UNIX editor options.
Combined with several other command line utilities available on most UNIX systems, such as nroff and troff, it is possible to produce documents with as many formatting changes and styles as any Microsoft Word document. In fact, I actually produced many of my graduate school papers using these utilities.
You don't have to worry about going through any special installation routines to get vi on your system. It should be there when the system is installed, because system administrators need vi to do most of their work, including creating system scripts. Redhat Linux does give you the option of installing or not installing particular editors on a system, but the chances of finding a UNIX system without vi is still small.
Author's note
This article is based on the vi version found in Solaris 7. Even though I'll
be discussing a specific version of vi, everything discussed here should work
fine in any flavor of vi, including the version that comes with the MKS Toolkit
for Windows.
Using vi
Before I get into how to use vi, it's important to understand that there are
two basic modes for vi: insert mode and command mode. Insert mode is the mode
where you type and things appear on the screen. Command mode is the mode where
you type and things happen, instead of text appearing. The easiest way to think
of command mode is to think of what happens when you cut, copy, and paste data.
By default, vi starts up in command mode, so no text will be entered when you type, unless you choose one of the commands to take you into insert mode. Most vi commands don't show anything on the screenyou just have to know how they work. To switch between insert and command modes, use the [Esc] key. If you're already in command mode, using [Esc] will indicate to vi that you have finished your command and it will attempt to execute the command. If you have not typed a command, pressing [Esc] in command mode will simply ring the terminal bell.
Now that I've discussed the modes vi operates in, you can start to use it. To start, open a terminal window on your workstation. You can start the editor by simply typing vi at the $ prompt and pressing [Enter].
You'll then see a blank document appear, filled with ~ characters down the left side of the page. It doesn't look terribly visual, but those ~ characters you see are just the indication of the bottom of the file. They will not show up in the file when you save it.
To edit a specific document or to give a blank document a name, you can also type vi filename, where filename is an existing file or the name you want the new file to have.
Do you need help with UNIX? 





1
Jeff Wolfe - 12/10/04
Nice article on a staple of the unix system. With an editor that has as many commands as vi has, it's always a challenge to limit the discussion to a "digestable" amount. Only two minor nitpicks with commands as stated:
1. Under the section Common Insert Commands, it says: "Once in a document, there are many ways to tell vi to go into insert mode other than just pressing [Esc]".
The way I read that is that by pressing "ESC" I can get to an insert mode. "ESC" is only used to go the other way - from one of the input modes back to command mode.
2. Under the section Cut and Paste and More, it says: "The characters can be a-z, and only lower case.".
If any of the named buffers are specified in lower case, any subsequent operation to that buffer overwrites the current content but if the buffer name is capitalized, ie "A3yy, then the object is then appended to the end of that buffer. Since there is no easy way to step through all 26 named buffers to view the contents, some of us take the "lazy" way and just keep shoving everything into one buffer! :-)
Again, it's a fine article and no offense is intended - just a minor clarification point or two.
» Report offensive content
2
Tom Mundar - 14/10/04
An 'autosave' feature is in all versions if vi that I remember using, although it has been so long that I have used any version than vim, that I can't say for certain that it is a standard feature.
While vi is running, it saves all of the actions that you do in a swap file. If something happens to your editing session, you can recover the file by using the -r (recover) option to continue editing where you left off. It is actually better than autosave because it records virtually every keystroke, instead of saving the whole file every X minutes.
» Report offensive content
3
Andrew - 17/06/07
editing
» Report offensive content