can vi/ex source beginning of text on startup?

Brian Martin brianm at bigtuna.UUCP
Wed Dec 5 08:20:22 AEST 1984


> I recall seeing a text file with ex commands at the beginning, e.g.
> 
> (some characters):set wrapmargin=10
> 
> It seemed like ex was meant to source the lines when starting up.
> Does this work and is it documented?

Sure, it works, but I don't know where it's documented.  Basically, what you
want to do is to automatically initialize your editing environment whenever
you invoke vi.  There are two ways to do it.  You can either

  1)  put the initializing commands in a file called ".exrc" in your HOME
      directory, or

  2)  put the initializing commands in a file, and place a ":source" command
      with a pointer to that file in the "EXINIT" environment variable.

I use the second approach (with "sh"), e.g., 

  EXINIT=":source $HOME/.exinit"; export EXINIT

My $HOME/.exinit file contains the following text (^[ is ESC, ^V CNTL-V, etc.):

set magic autoindent shell=/bin/sh wrapmargin=1 w1200=12
map #1 :w!^V^MGo^V^[:$!mspell^V %^V^M
map #2 0i/\<^V^[A\>^V^["zdd at z
map #3 :/^Possible^V misspellings:$/+1,$!dict.addto^V^M
abbr qmc Queen's Medical Center
abbr jabsom John A. Burns School of Medicine
abbr dc discontinue
abbr ddx differential diagnosis
abbr dx diagnosis
abbr hx history
abbr meds medications
abbr pe physical exam
abbr perrla pupils are equal, round, and reactive to light and accomodation
abbr pta prior to admission
abbr ro rule out
abbr rx treatment
abbr ss symptoms/signs
abbr sx symptoms
abbr tx therapy

Funny thing--whoever compiled vi for our machine severely resctricted the
number of macros and abbreviations that I can define.  What you see defined
above is the maximum that can be defined on our machine (a Dual running System
V).  Nevertheless, I find the abbreviations and function key mappings very
useful.

Brian Martin
UUCP: ..!{dual,ihnp4,vortex}!islenet!bigtuna!brianm



More information about the Comp.unix mailing list