pag@hao.UUCP (Peter Gross) (04/24/84)
I can see both the utility and security problems with the above. An easy way around the latter is to only do it when the .exrc file is owned by the invoker of ex/vi (maybe that's what's done now). --peter gross hao!pag
mjl@ritcv.UUCP (Mike Lutz) (04/26/84)
Adding suffix dependent setup to vi is straight forward. I have a shell script in my own 'bin' that uses the suffix to select initialization commands that are then grafted onto my generic EXINIT environment variable. I even set have a function key set up to change modes in case the suffix guess is wrong. I think this is in general preferable to (and less annoying than) embedding the commands in the source file itself. Overhead for all this is about 1 CPU second on an 11/780 -- hardly noticeable unless the load average zooms out of sight. If I really wanted, I guess I could hard code it all in C and get the overhead down even further, but it's not been worth the bother up to now. Mike Lutz -- Mike Lutz Rochester Institute of Technology, Rochester NY UUCP: {allegra,seismo}!rochester!ritcv!mjl ARPA: ritcv!mjl@Rochester.ARPA
rcd@opus.UUCP (Dick Dunn) (04/28/84)
<> >Adding suffix dependent setup to vi is straight forward. I have a >shell script in my own 'bin' that uses the suffix to select >initialization commands... What a novel idea! I'm glad that someone out there remembers that it is possible to do things without either writing a special-purpose program or adding YA feature to an existing program. I remember that we used to do things like that with UNIX...wait a minute... Seriously, I'm amazed at the way programs pile up features when there are other good ways (shell scripts foremost) for users to tailor their environments. -- ...Cerebus for dictator! Dick Dunn {hao,ucbvax,allegra}!nbires!rcd (303) 444-5710 x3086
ado@elsie.UUCP (05/12/84)
A dumb way to execute a fixed set of commands when you edit a file is outlined below. The example is for C shell users. In your ".login" file, have a line like: setenv EXINIT "map #1 :source %\! " Then, if you have a set of commands you want to use when you edit a file named editable put these commands in a file named editable! where the trailing exclamation point above is part of the name. Finally, when you begin editing the file, tap function key 1 to execute the desired commands. You can, of course, use some other convention in naming the files that hold the editor commands; for example, setenv EXINIT "map #1 :source %.exrc " Tapping the function key to execute the commands means more work for you-- and also gets around security problems of embedded commands. -- UNIX is an AT&T Bell Laboratories trademark. -- decvax!harpo!seismo!rlgvax!umcp-cs!elsie!ado (301) 496-5688
jerryp@tektronix.UUCP (05/17/84)
Like many people, I want different vi options set for writing a program than for working on a text file. Here's how I do it: Instead of putting mode lines within each file, or writing extensions to the filenames, I've got several different .exrc files... one for each vi mode I'd like to use. I have aliases that let me select the .exrc file I want. And, I have vi aliased so that, when I start it up, it tells me which .exrc file is in use. Here are the lines (with comments) from my .cshrc file: ----------------------------------- setenv EXSTAT "text" # initialization for 'vi' alias #---- THESE ALIASES RESET THE .exrc FILE ----# # SET 'vi' FOR 4-CHARACTER TABS/SHIFTS (RING BELL AS REMINDER): alias 4vi 'cp ~/.exrc4 ~/.exrc; setenv EXSTAT "programming^G"' # SET 'vi' FOR 8-CHARACTER TABS/SHIFTS: alias 8vi 'cp ~/.exrc8 ~/.exrc; setenv EXSTAT "text"' # SET 'vi' FOR QUICK WORK ON BUSY SYSTEM (NO .exrc FILE): alias qvi 'rm ~/.exrc; setenv EXSTAT "quick"' #---- THESE ARE THE vi ALIASES. ONE SETS THE vi MODE FIRST ----# # show whether using ~/.exrc4 or ~/.exrc8: alias vi 'echo "MODE: "$EXSTAT; /usr/ucb/vi \!*' # call 'vi' with a search # (must use 8vi because search requires a 'wrapscan', and .exrc8 has ws set) alias vs '8vi; vi +/\!*' ----------------------------------- The $EXSTAT variable remembers which .exrc? file (.exrc4, .exrc8) has been copied into the .exrc file. Also, as was mentioned in another unix-wizards article, you can't start "vi" with a search (vi +/PATTERN) unless the wrapscan option has been set... so, I start the "vs" alias with an "8vi". (Please direct all flames about BSD and C-shell to /dev/null.) --Jerry Peek, Tektronix, Inc. US Mail: MS 76-036, P.O. Box 500, Beaverton, OR 97077 uucp: {allegra,decvax,hplabs,ihnp4,mit-eddie,ucbvax}!tektronix!jerryp CSnet: jerryp@tek ARPAnet: jerryp.tek@csnet-relay Phone: 503/627-1603