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:
Make sure there are no blank lines, because anything below the first blank line will be ignored.
You may use the forms ab, map, and set because commands in an .exrc file are not required to begin with a colon (:).
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:
sample exrc file
In the next lesson, you will learn how to edit multiple files in the same vi session.