Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!sdd.hp.com!hplabs!hpfcso!hpldola!hp-lsd!was From: was@hp-lsd.COS.HP.COM (Bill Stubblebine) Newsgroups: comp.editors Subject: Re: vi question Message-ID: <14420005@hp-lsd.COS.HP.COM> Date: 31 Aug 90 17:53:18 GMT References: Organization: HP Logic Systems Division - ColoSpgs, CO Lines: 38 mende@athos.rutgers.edu (Bob Mende Pie): > I want to set up a map statement in vi to allow a program to be run with > all of the files that vi is [editing] as arguments. I know of no vi internal command that will do what you ask. (That is not to say, of course, that there isn't one. :-) ) As an alternative, why not invoke vi via a shell script that makes the file names visible in the shell environment: export files="file1 file2 file3" (or export files=$*, to generalize) vi "+map L :!ls $files^M" $files (substitute your favorite shell command or mapped key in the 'map' directive) Obligatory control character caution: Assuming you are editing the above shell script with vi (seems logical, given the basenote), the ^M (carriage return) code in the map command is entered as cntl-V cntl-M. Putting the ^M in the map directive relieves the operator of the terrible burden of hitting 'return' after hitting the mapped character. Then, whilst in vi, typing 'L' will execute the shell escape with the desired file names. This works for me. This method has one limitation: changes to the argument list made within vi, e.g., ":n file4 file5 file6", won't update the shell environment. If you need to invoke vi with flags, the shell script may need to create separate lists (under different environment variable names) to hold flags and file names passed to the script above on the command line. Creating these separate lists shouldn't be too hard to do (see getopt(1)). Bill Stubblebine Hewlett-Packard Logic Systems Div. 8245 N. Union Blvd. Colorado Springs, CO 80920 was@hp-lsd.hp.com (Internet) (719) 590-5568