You can store commands and settings that you want executed any time you start the in a file called .exrc in your home directory. You can modify the .exrc file with the vi editor, just as you can any other text file.
If you don't yet have an .exrc file, simply use vi to create one. Enter into this file the set,, and commands that you want to have in effect whenever you use vi or ex. A sample .exrc file looks like this:
set nowrapscan wrapmargin=7 set sections=SeAhBhChDh nomesg map q :w^M:n^M " To swap two words, put cursor at start of first word and type v: map v dwElp ab ORA O'Reilly & Associates, Inc.
^M characters are RETURNs.
Make them by pressing
Lines that start with a double quote (
") are comments.
Since the file is actually read by ex before it enters
vi, commands in .exrc should not have a preceding
In addition to reading the .exrc file in your home directory, vi will read a file called .exrc in the current directory. This allows you to
If your .exrc file doesn't seem to be working, watch carefully for error messages just as vi starts, before it clears your screen. If you can't read them quickly enough, start ex instead of vi. The q! command quits ex:
exNo tail recursion :
The tricks in article 42.8 may also be useful.
- from O'Reilly & Associates' Learning the vi Editor, Chapter 7