Learning the VI Editor

A powerful editor can make your life as a programmer significantly easier. The standard editor in the UNIX world is called "vi", pronounced either like "vie" or "vee-eye" depending on the speaker. Most people don't actually use the classic vi any more, but one of the many improved clones. Today, we are going to use the "vimtutor" program which tutors you in the use of vim: one of the vi clones (the manual page for vim defines it as "vim - Vi IMproved, a programmer's text editor").

The "vimtutor" program

The vimtutor program is a simple program that launches you into the vim editor with a tutorial file already loaded into the editor. All you have to do is read the file that you see in the editor and follow the instructions there.

Getting started

At the command prompt, type vimtutor . That should put you into the tutoring program. If by any chance it doesn't work, you might try logging into another of our UNIX systems; it should work on all of them, but if it doesn't on the one you connected to, go to matthew and run it from there. Run through the whole tutorial, reading the directions and completing the exercises. Please return this filled in sheet using the online submission system. Your TA should show you how to submit your assignment. This is how you will be turning in all of your assignments for this class. It will become part of your lab grade for today.

Questions

  1. What vi command character do you type to delete the character under the cursor?
  2. What do you type to quit vi without saving any changes?
  3. What does pressing <ESC> do?
  4. What do you type to delete the next three words?
  5. What do you type to undo the most recent action/change that you made in the editor?
  6. What does the '$' character represent in commands?
  7. How do you move from anywhere in the file directly to line 37?
  8. How do you type to locate the opening parenthesis that matches the closing parenthesis marked by the cursor?
  9. What does typing :set ai in command mode do? First type :set ai and write some C++ code, then type :set noai and type some more.
  10. If the cursor is at the end of a line and you want to enter text after the last character, what do you type?
  11. What does :7,10d do in command mode?