Vi For Smarties

Quiz Two


  1. Your friend is making it hard for you to concentrate. At one point, you decide to move lines 20 through 80 inclusive to the point between line 1 and line 2, so you cut them out of the text by moving to line 20 and typing 61dd. Before you can paste them to the desired location, however, your friend points out that you have an extra "the" in one of your lines, so you delete it with dw to shut her up. Oops. Now how do you recover those 61 lines you had previously cut and then paste them to the desired location at the top of your file?
    ANSWER

  2. Your friend finally found something more fun than pestering you. Candy. While she is out looking for a vending machine, you notice that you have been repeatedly typing the phrase, "deoxyribonucleic acid strands" (without the quotes) because your mean instructor will not allow students to abbreviate. How would you arrange it so that whenever you type the word "dnas" (without the quotes) in insert mode, it immediately expands to the correct phrase?
    ANSWER

  3. She's still out looking for candy. You are feeling better now that you don't have to keep typing that long phrase over and over again. But now you want the text to "wrap" for you whenever it goes beyond column 72, and you don't want to have to see it coming each time and manually hit Enter yourself. You also need to use the restroom, and you have to log out each time you leave this room. Quickly, how do you set vi to wrap the text for you and then make both this setting and your "dnas" macro from the previous question permanent?
    ANSWER

  4. You knew this would happen. You return from the restroom to find that your friend has purchased her candy and is now occupying your seat. There are no other available terminals, and you need to get your work done. Your friend offers to forfeit her game of Tetris and let you have the terminal if you help her edit a quick reply to one of her email messages. She is too lazy to keep hitting Enter three times, going up two lines, and hitting Space five times whenever she wants to insert her reply in the middle of part of the original sender's message. How would you map the @ to do this in Vi?
    ANSWER


Until you have mastered everything on this page, you are not ready for Lesson Eight.


Copyright © 2001 jerry_y_wang@yahoo.com. All rights reserved.