This chapter introduces the vi text editing program. The objectives important to this chapter are:
Concepts:The chapter begins with background on different types of editors. It divides the field into two types:
The book then tells us that vi is available in two versions:
When editing files with vi, you should be aware which of its two modes you are in:
Basic Editing Tasks
You can start vi two ways. Just enter vialone on the command line to start it with a blank file. Enter "vi" followed by a space and the name of a file to open that file (or create it, if it does not exist). vi filename To enter the Input mode, press the letter i in the Command mode. (Remember, vi starts in the command mode.) Use the Enter key at the end of lines in vi. vi does not word wrap. To save a file in vi, switch to the Command mode by pressing the Escape key. You can press it a number of times to be sure. If the computer beeps when Escape is pressed, you are in the Command mode. Now comes the fun part. Some vi commands (not all) start with a colon. The save command is one of them. Type the colon, and follow it with the letter w (for write) and, if you want to quit vi, the letter q. Either of these commands may be issued alone. Doing them together is a time saver when you are done word processing, but the :w command alone is better if you just want to save every few minutes. There is a chart of vi single-key commands in section 4.3.2 which you should practice using. It is recommended that the student will benefit from carrying out the instructions on the next several pages. Note that on some UNIX systems the arrow keys will not work in vi. An odd feature for a screen editor, but not all keyboards had arrow keys when vi was written. To move the cursor, enter the Command mode, and press h for left, j for down, k for up and l for right. There are several deletion-related commands in the Command mode. See Table 4-4. Noteworthy ones:
Quitting vi is not difficult. As noted above, you can enter the Command mode and issue the :q command. You can also use:
A memory buffer is a temporary space in memory for working storage. Vi opens such a buffer and stores your file in it while vi is running. Changes all go into the buffer, and not to disk, until a write command is issued. For those who had trouble finding an answer to the calendar question posed in class ("Why does the calendar for 1752 do what it does?"), try this web site: Calendopaedia. |