Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site sdcsla.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxb!mhuxn!mhuxm!mhuxj!houxm!whuxlm!akgua!sdcsvax!sdcsla!west From: west@sdcsla.UUCP (Larry West) Newsgroups: net.unix Subject: Re: Can you access the current file name in a vi macro? Message-ID: <768@sdcsla.UUCP> Date: Fri, 25-Jan-85 05:25:32 EST Article-I.D.: sdcsla.768 Posted: Fri Jan 25 05:25:32 1985 Date-Received: Mon, 28-Jan-85 05:26:49 EST References: <153@wanginst.UUCP> Reply-To: west@sdcsla.UUCP (Larry West) Distribution: net Organization: UC San Diego: Institute for Cognitive Science Lines: 26 Summary: In article <153@wanginst.UUCP> diamant@wanginst.UUCP (Ira Diamant) writes: > > Does anyone know if there is a way to access the name of the current >file in vi? I want to build a small template generator using macros, but >I have not been able to find this information in the documentation. > > Thanks in advance Well, sort of. The character "%", used in shell-escapes (":!" or "!" [e.g., "!!" for one line]) is expanded to the current filename. Likewise, "#" is expanded to the alternate filename, if any. For exmaple, try this command: :!ls -l % So you could put that command into a mapping (and probably a macro but not an abbreviation) by doing something like: :map V :!ls -l %^V^M This will not work on older versions of VI for various reasons. Hope this confuses you at least a little. -- --| Larry West, UC San Diego, Institute for Cognitive Science --| UUCP: {decvax!ucbvax,ihnp4}!sdcsvax!sdcsla!west --| ARPA: west@NPRDC { NOT: }