vi editing  «Prev  Next»

Storing Custom Settings for vi - Exercise

Course project: Creating an .exrc file


Objective:Create an .exrc file to store some custom vi settings.

Exercise scoring


You will receive 5 points for this exercise.

Background/overview


As you work on the eCyberCom web site, you will frequently use vi to edit files. To make editing easier, you have decided to customize vi by adding commands to your .exrc file. Your course account already gives you an .exrc file, so you will edit the existing file rather than creating a new one.
In this exercise, you will define a keyboard map, an abbreviation, and a vi configuration option.

Instructions, Part I

  1. Log in to your course account.
  2. In your home directory, use the vi editor to open the file named .exrc.
  3. Define some text abbreviations, keyboard maps, or configuration options that you would find useful while editing the web site files.
  4. When you are finished, save your changes and quit vi.
  5. Test your new .exrc settings. Using vi again, open an existing file or create a new file.
  6. In the file, use the :ab, :map, and :set commands to list your abbreviations, maps, and options. Do they appear as you defined them in .exrc?
  7. Now edit your .exrc file and add intentional mistakes. For example, add a blank line as the first line, or use uppercase letters for the commands (AB, MAP, SET).
  8. Write and quit the .exrc file.
  9. Start another vi session, and check your settings again by entering :ab, :map, and :set. Are your intended .exrc settings listed this time?
  10. Fix your .exrc file..
  11. When you are done, quit vi and log out.

You can define multiple options using a single set command. For example, in your .exrc file, you can type a single line that reads, set ic showmode.

Instructions, Part II

List the .exrc settings you created for Part I and describe what each command does and why you created it.

Hints

You will notice that your .exrc file already contains the line set showmode. As you add new lines of text, it doesn't matter whether you add them above or below the existing line. It doesn't matter in what order you place your custom settings.
In an .exrc file, using a colon (:) before the set, ab, and map commands is optional.
If you made errors while editing your .exrc file, your custom settings might not take effect as you expect. You can check your results byvusing :ab, :map, and :set to list your definitions. To fix errors, open the .exrc file in vi and make thevnecessary edits.

Submitting your exercise

Submit your exercis clicking the submit button below.