-------------------------------- DAT2330 - Unix - Prof. Ian Allen -------------------------------- Here are questions you should be able to answer. You will likely find questions similar to these on tests and exams. Chapter 8 - The VI Editor. Note: The ACADAIX and Floppix versions of VI are not as advanced as the VI described under Linux. You may find that some of the features described in the text only work on a full installation of Linux (e.g. the "Getting Help" commands). ACADAIX has an old version of "vim" (Vi iMproved) installed, in which the ":help" command does work. Omit the "optional" material in this chapter on first reading. You can get by in VI with knowing how to read in a file, delete and append single characters and lines, and write the file back out. Advice: The more you learn about VI, the faster you will edit files and the more useful you will be as a Unix programmer. Almost every letter, upper and lower case, is a VI command. The more you learn, the faster you can edit. While you may begin by learning to delete a word using ten "x" commands, eventually you should evolve into knowing how to use the single "dw" command. Recommended: Create a file named .exrc in your home directory containing this command (see the text, p.229): set showmode That will enable VI to remind you when you are in INPUT MODE. Some people also like to have "set number" in their .exrc. -------- WARNING! -------- Make sure your terminal is correctly configured before you enter VI! If you use telnet under Windows, make sure you have NO SCROLL BARS VISIBLE! Set the correct number of lines and correct terminal type. (This won't be a problem for people working on the Floppix console, since the Floppix console isn't a telnet window.) On ACADAIX, the "resize" command is useful to set the number of lines correctly after you telnet into the machine: $ resize This is outlined in detail in the "Using Telnet" web page. --------------------------------------- Absolute bare minimum basic VI commands --------------------------------------- ESC a i x dd :w file :q! The above commands, plus the arrow keys, will perform most any edit on any file you have. All the other things in VI simply make the editing faster. Some of the other VI commands make the editing much, much faster. [Compare "dd" (delete a whole line) with typing 80 "x" commands!] ------------------------ What to learn Next in VI ------------------------ Other useful things to know in VI, in vague order of importance: u . p P r o O 5dd 10x h j k l 0 ^ $ H L M A I U cc s f F !! :x :$r file :set showmode :set autoindent :set wrapmargin=5 :set number Learn a new command every week from Chapter 8. ---------------- Review Questions ---------------- - Chapter 8 non-Advanced Review Questions: On ACADAIX or Linux: 1 - 10 (all) - Chapter 8 Advanced Review Questions: none (but read the paragraph Advice, above)