4. Startup File
 Having explored vi commands somewhat, we are now ready to create 
a default editing environment through the use of .exrc, 
the configuration file which resides in user's home directory.
 .exrc typically contains at least three types of entries:
  
- set commands to create preferred editing environment 
 
- map commands to assign functions or macros to keys 
 
- ab commands to either map abbreviations or automatically 
 correct common spelling errors
 
When mapping escape sequences of some keys, we may need to 
quote them, that is, to insert them literally.  This can 
be accomplished in vi by issuing a text input command and pressing 
Ctrl-V before the key we wish to quote is pressed.
 Now let's look at a sample .exrc:
  
set autoindent 
set wrapmargin=8 
set ignorecase 
map     #4      !}fmt^M 
ab      teh     the 
ab      cutsomer customer 
 Lines 1 and 2 set autoindent mode on and turn on wordwrap at column 
72. Line 3 specifies that all searches are to be case insensitive. 
Line 4 maps function key 4 to reformat from the cursor position 
to the end of the paragraph.  Finally, lines 5 and 6 map some 
common misspellings to the correct spelling.  Note that ^M 
on lines 4 and 5 are created by pressing Ctrl-V and then 
hitting Ctrl-M.
 With a little creativity you can make vi look as personal as you wish.
 NOTE: After creating .exrc make sure that EXINIT 
environment variable is not set as it would overwrite whatever 
settings you entered into .exrc.  You can verify whether 
the EXINIT variable is set using this command from the UNIX command 
prompt:
  
$ set | grep EXINIT 
 If you see no output, you're fine.
 Make sure that .exrc contains no blank lines - they 
are not allowed.
  
/*  The article above and any accompanying files are freely 
 *  distributable, but please leave this notice and the text intact. 
 *  Home for this document: http://www.infobound.com/vi.html 
 *  Copyright (C) 1994, 1999 Tony Thomas 
 *  Contact author through email:tony@infobound.com 
 *  Last revision Feb 23, 1999 
 *  UNIX is a trademark of X/Open 
 */ 
rate this article:current rating: average rating: 1.2 (84 votes) (1=very good 6=terrible)
Your rating:
back