-------------------------------- 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). The Linux test machine has a full installation of VI (VIM). 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 better your mark will be on tests and exams. VI skill is essential to you 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. If you are using "vi" (not "vim") on ACADAIX, create a file named .exrc (or .vimrc) in your HOME directory containing this command (see the text, p.229): set showmode That will enable the IBM standard version of VI to remind you when you are in INPUT MODE. (Some versions of VI (VIM) turn this on by default.) Some people also like to have "set number" in their .exrc. The corresponding file for VIM is ".vimrc" and some people like to have "syntax off" in it. -------- WARNING! -------- Make sure your terminal is correctly configured before you enter VI! (See the "Using Telnet" web page off the course home page.) If you use telnet from under Windows to connect to a Unix machine, 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. -------- TUTORIAL -------- Complete this short VIM tutorial on the Linux test machine by copying the tutorial file into your directory and editing it: $ cd $ cp /usr/share/vim/tutor/tutor tutor $ vim tutor Follow the instructions in the tutorial. --------------------------------------- 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 and get you better marks in less time. 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 :syntax off To improve your skill, 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)