Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 v7 ucbtopaz-1.8; site ucbtopaz.CC.Berkeley.ARPA Path: utzoo!watmath!clyde!cbosgd!cbdkc1!desoto!packard!hoxna!houxm!whuxlm!akgua!mcnc!decvax!ucbvax!ucbtopaz!gbergman From: gbergman@ucbtopaz.CC.Berkeley.ARPA Newsgroups: net.unix Subject: Re: Can you access the current file name in a vi macro? Message-ID: <693@ucbtopaz.CC.Berkeley.ARPA> Date: Thu, 31-Jan-85 13:57:41 EST Article-I.D.: ucbtopaz.693 Posted: Thu Jan 31 13:57:41 1985 Date-Received: Mon, 4-Feb-85 03:33:11 EST References: <768@sdcsla.UUCP> <153@wanginst.UUCP> Organization: Univ. of Calif., Berkeley CA USA Lines: 28 In article <768@sdcsla.UUCP> west@sdcsla.UUCP (Larry West) writes: >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. West points out that the character % in command escapes is expanded to the current filename. If one only wants to _s_e_e the current filename, the command ^G or :file will show that. But if one wants to get it into the file (other than by copying by hand from the bottom line the result of one of the above commands) then an application of the feature West mentioned is needed. The command :[address]r !echo % seems the best way. It can be used in editor scripts as well as mappings. The disadvantage is that shell escapes are slow. And a general disadvantage of using % is that it shows the current file name *as one originally called it*, not in any uniform format -- It will be shown relative to the directory one was in when one entered vi, unless one used an absolute address or called it relative to one's own or another's home directory, in which case it will have an absolute address. George Bergman Math, UC Berkeley 94720 USA ...!ucbvax!gbergman%cartan.Berkeley