DistributedNetworks DistributedNetworks


vi editing  «Prev  Next»
Lesson 7 Storing custom settings for vi
Objective Use the .exrc file to store vi settings

Storing custom settings for vi

When you define new text abbreviations, keyboard maps, or configuration options within a vi session, the custom settings are valid only for that session. Once you quit vi, the changes are lost. You can make your settings permanent by saving your :ab, :map, and :set commands in a configuration file called .exrc, which must reside in your home directory. The .exrc file is similar in concept to .cshrc, the configuration file for the C shell. When you start vi, it checks your .exrc file and runs any commands it finds there. This makes your custom vi settings available every time you use vi.
You can still change your settings within vi, but remember that changes you make within a session are temporary. When you quit vi and start it again, vi reverts to whatever settings are defined in the .exrc file.

Guidelines for editing your

.exrc file The following pointers will help you edit your .exrc file:
  1. Make sure there are no blank lines, because anything below the first blank line will be ignored.
  2. You may use the forms ab, map, and set because commands in an .exrc file are not required to begin with a colon (:).
  3. You may 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. The following MouseOver shows a sample .exrc file:

After creating an .exrc file (using vi, for example), you can use the cat .exrc command to display the contents. Whenever vi is started, it reads the .exrc file

sample exrc file
In the next lesson, you will learn how to edit multiple files in the same vi session.

Storing Custom Settings-for Vi- Exercise


Click the Exercise link below to practice creating an .exrc file.
Storing Custom Settings-for Vi- Exercise