home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 30.5 Edits Between Files Chapter 30
vi Tips and Tricks
Next: 30.7 Using Buffers to Move or Copy Text
 

30.6 Local Settings for vi and ex

In addition to reading the .exrc file in your home directory (4.9 ) , many versions of vi will read a file called .exrc in the current directory. This allows you to set options that are appropriate to a particular project.

For example, you might want to have one set of options in a directory mainly used for programming:

set number lisp autoindent sw=4 terse
set tags=/usr/lib/tags

and another set of options in a directory used for text editing:

set wrapmargin=15 ignorecase

Note that you can set certain options in the .exrc file in your home directory and unset them (for example, set wrapmargin=0 noignorecase ) in a local directory.

NOTE: In System V, Release 3.2 and later, vi doesn't read &.exrc files in the current directory unless you first set the exrc option in your home directory's .exrc file:

set exrc

This mechanism makes it harder for other people to place, in your working directory, an .exrc file whose commands might jeopardize the security of your system.

You can also define alternate vi environments by saving option settings in a file other than .exrc and reading in that file with the :so command. For example:

&:so .progoptions

Local .exrc files are also useful for defining abbreviations (30.31 ) and key mappings (31.2 ) . When we write a book or manual, we save all abbreviations to be used in that book in an .exrc file in the directory in which the book is being created.

You can also store settings and startup commands for vi and ex in an environment variable (6.1 ) called EXINIT (30.35 ) . If there is a conflict between settings in EXINIT and an .exrc file, EXINIT settings take precedence.

- TOR from O'Reilly & Associates' Learning the vi Editor , Chapter 7


Previous: 30.5 Edits Between Files UNIX Power Tools Next: 30.7 Using Buffers to Move or Copy Text
30.5 Edits Between Files Book Index 30.7 Using Buffers to Move or Copy Text

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System