Before you start
The vi editor is the de-facto UNIX® and Linux® text editor. It exists on almost all systems and is available for Windows®, DOS, Macintosh, OS/2, SGI, and many other platforms. If you don't already know vi or aren't comfortable using it, then you owe it to yourself to take this tutorial and get up to speed with one of the most popular and powerful Linux/UNIX visual editing programs.
The main objective is to help you learn vi quickly. One thing makes it difficult to learn vi -- vi has lots of commands. To use vi effectively, you need to memorize quite a few. This can take a long time, and one of the goals of this tutorial is not to take up a lot of your time. So, initially, I have a challenge -- how exactly can I help you to memorize lots of commands in a short time?
To tackle this challenge, as we proceed through this tutorial, we're going to gradually put together a vi "cheat sheet". This sheet will contain all the important vi commands. After you've completed this tutorial, you'll be able to refer to this cheat sheet if you forget a particular command. Over time, as you memorize commands, you'll gradually become less dependent on the cheat sheet.
This tutorial has no prerequisites. It uses several techniques to help you learn. First, I'm going to describe how a particular command works, as you'd expect. Then, I'm going to ask you to try to use the command in vi (for practice), and then I'm going to ask you to transcribe the command to the cheat sheet (for later reference). If you want to learn vi quickly, it's important that you perform all these steps. Trying out a command in vi and transcribing the command onto your cheat sheet will help you to memorize the command.
There are many versions of vi, and I'm going to show you how to use a version of vi called "vim." vim is very popular and has a number of extensions that make vi a lot nicer (whenever I demonstrate a vim-specific command, I'll make a note of it). To install vim, see Resources at the end of this tutorial for a link to the vim home page. Vim is a text editor that runs in a terminal window or terminal session. Figure 1 shows a screen shot of vim with the XML source for this tutorial opened in a terminal window.
Figure 1. Running vim
In addition to an enhanced command-line vi, vim also comes with a nice GUI editor called gvim. Figure 2 shows a screen shot of gvim with the same XML source that you saw above.
Figure 2. Running gvim
If you're a vi newbie, try to get gvim running on your system. Using vi from a GUI can make things a bit easier for beginners.




