Xref: utzoo comp.unix.questions:14142 comp.sys.att:6642 Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!n8emr!uncle!jbm From: jbm@uncle.UUCP (John B. Milton) Newsgroups: comp.unix.questions,comp.sys.att Subject: Re: Vi Keywords: Vi nroff macro Message-ID: <550@uncle.UUCP> Date: 8 Jun 89 19:32:15 GMT References: <1103@adds.newyork.NCR.COM> Reply-To: jbm@uncle.UUCP (John B. Milton) Organization: U.N.C.L.E. Lines: 38 In article <1103@adds.newyork.NCR.COM> tanya@adds.newyork.NCR.COM (Tanya Katz) writes: >In article <13816@dartvax.Dartmouth.EDU> Andy Behrens write: >|In article <19890@adm.BRL.MIL> thoyt@ddn-wms.arpa (Thomas Hoyt) writes: >|> Can Vi reformat a paragraph, justifying it properly.... >| >|If you put the following line in your .exrc file, you can type "V" when >|the cursor is anywhere in a paragraph, and the entire paragraph will be >|rejustified by being piped through "fmt". >| >| map V 0}!{fmt^M} >| >Well I liked this idea, but I usually don't like to overwrite the >vi file, and wanted to just produce an nroff file from within vi. > >SO... here are my macros: > > map M :!less %.out^M^M > map V :!nroff %>%.out^M^MM^M > >This brought up an interesting question of file name manipulation >from within vi, and passed to the shell. > >% = the current file name, but how can I truncate it to just >the prefix if it is something like: > name.1 >to get: > name >or better yet `basename name`?? The prpgram basename can take a second argument, which is a string to remove from the end of the path after the leading directory has ben stripped off. So `basename /a/b/c/file.out .out` will be "file", and `dirname /a/b/c/file.out`/`basename /a/b/c/file.out .out` will be "/a/b/c/file" John -- John Bly Milton IV, jbm@uncle.UUCP, n8emr!uncle!jbm@osu-cis.cis.ohio-state.edu (614) h:294-4823, w:466-9324; N8KSN, AMPR: 44.70.0.52; Don't FLAME, inform!