tanya@adds.newyork.NCR.COM (Tanya Katz) (06/07/89)
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`?? Tanya ------------------------------------------------------------------------------ ### ###### ###### ##### Tanya Katz (516) 231-5400 x430 # # # # # # # # # # # # # ##### ...uunet!ncrlnk!adds!tanya ####### # # # # # tanya.katz@adds.newyork.ncr.com # # ###### ###### ##### Applied Digital Data Systems, Inc. 100 Marcus Blvd., Hauppauge, NY 11788 ------------------------------------------------------------------------------
jbm@uncle.UUCP (John B. Milton) (06/09/89)
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!