vi: just the basics


LESSON 0

0:0 You invoke vi by typing vi.

0:1 vi has two modes, input mode and command mode. input mode is where you type stuff, and command mode is where you do stuff with your file (like save it or delete lines). When you start vi, you are in command mode.

0:2 You get from input mode into command mode by pressing the escape key. There is no other way to get from input mode to command mode. If you press escape when you're already in command mode, that's ok. It will just beep at you. Try it! That's how you can check what mode you're in and get out of trouble and stuff. Just press escape!

0:3 You get from command mode to input mode by using any of the several different input commands. The input commands are a, i, o, A, I, and O. There is an important difference between little letters and capital letters - see if you can figure it out. Here's what the input commands do:

Remember: there are many many more input commands, so don't get discouraged if you can't easily do what you want. These commands will be discussed in LESSON 1.

0:4 In command mode, you can move around, but not in input mode. The important movement commands are h, j, k, and l. Here's what the important movement commands do:

Remember: there are many many more movement commands, so don't get discouraged if you can't easily do what you want. These commands will be discussed in LESSON 1.

0:5 In command mode, you can edit your text by deleting and putting text anywhere you want. Here's what some of the editing commands do:

Remember: there are many many more editing commands, so don't get discouraged if you can't easily do what you want. These commands will be discussed in LESSON 1.

0:6 In command mode, you can search for things in your text by typing / followed by what you want to search for. That searches forward. A ? followed by text searches backward. There are a lot of special characters that have special effects in search strings. Some of them are: *, ., [, ], \, ?, ^ and $. They will be explained in LESSON 1. Remember: there are many many more search commands, so don't get discouraged if you can't easily do what you want. These commands will be discussed in LESSON 1.

0:7 In command mode, you can save your current file or edit another one. Commands like these all begin with a colon (:). Here's what some of the colon commands do:

Remember: there are many many more colon commands, so don't get discouraged if you can't easily do what you want. These commands will be discussed in LESSON 1.

0:8 In command mode, there is a special command to save and quit. It is not a colon command. It is ZZ. Not zz.

0:9 Always remember: a humble and quiet vi user appears to know more than a pretentious and loud one.

Here endeth the lesson


vi evangelical series / corby@intuit.com
January 1995 (updated April 6, 1998)