Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!world!kaspar!ires From: ires@kaspar.UUCP (Bruce R. Larson) Newsgroups: comp.unix.misc Subject: Re: A question on .exrc while using vi Summary: looks like you're trying to use modelines during initialization. Keywords: exrc vi Message-ID: <21@kaspar.UUCP> Date: 4 Dec 90 18:33:25 GMT References: <5315@graphite20.UUCP> <13458@chaph.usc.edu> Lines: 55 In article <13458@chaph.usc.edu>, jeenglis@alcor.usc.edu (Joe English Muffin) writes: > joshi@motcid.UUCP (Abhay B. Joshi) writes: > > > >I set up a .exrc in the current directory which looks like (2 lines): > > :g/the/ s//an/g > > > >Now I tried to do a 'vi text-file', I got a coredump! About 10 times. > >Then I deleted the .exrc file and put the command in EXINIT. > >I got a coredump again. (No coredump if neither .exrc nor EXINIT exists) > > Just a guess: I think that vi executes all the commands > in .exrc BEFORE reading the file to be edited. > Joe is correct. When vi starts it searches for initialization info: 1st) from an EXINIT environment variable. If EXINIT doesn't exist, then vi looks for a $HOME/.exrc and reads initialization info from that. 2nd) from a .exrc in the current directory. [NOTE: Some SysV3.2.* `vi's have a `:set noexrc' option that turns off sourcing of .exrc in the current directory.] > I'm not sure what your actual application is, but you're better > off mapping a macro to the substitute command. > Here are some other things to try. 1) For simple changes, like the single global listed above, you can do this vi + ":g/the/ s//an/g" filenames or the modern equivalent vi -c ":g/the/ s//an/g" filenames 2) Use modelines. This method is frowned upon. (!Modelines are considered dangerous and should be used with caution!) *) Put a .exrc file in the current directory containing `set modelines'. *) In the first or last 5 lines of the file in which you want the command executed, either vi: `command' : or ex: `command' : You may want to place the above string inside of a comment, so your command would look like /* vi: :g/the/ s//an/g : /* modeline command */ In response to the coredump issue, I'm not sure why vi was dumping core, but it looks as if you were trying to implement modelines in an illegal way (i.e., modelines go in the file to be edited, not with the init info). Bruce -- Bruce R. Larson | The drug problem in the US is so Integral Resources, Milton MA | vast that we need to recognize that Internet: ires.com!blarson@cs.umb.edu | it is primarily a social problem, Uucp: ..!cs.umb.edu!ires.com!blarson| not a criminal problem.