Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!aplcen!ginosko!soleast!howell From: howell@Soleast.Solbourne.COM (Bob Howell) Newsgroups: comp.unix.questions Subject: Re: Centering lines in vi Message-ID: <1989Sep13.023805.507@Soleast.Solbourne.COM> Date: 13 Sep 89 02:38:05 GMT References: <2283@umbc3.UMBC.EDU> <5520004@hplsla.HP.COM> Organization: Solbourne Computer, Inc; Eastern Regional Office Lines: 22 > Does anyone know a combination of commands that will center a given line > (or better yet, a range of lines) in vi? > > Rouben Rostamian Phone: 301 455-2458 Place the following script in your ~/bin subdirectory. Name it 'center'. Then execute it from within your vi session as follows: :m,n ! awk -f ~/bin/center where m is the beginning line number and n the ending line number of the lines you want centered within the file. Note, this is not my code. I got it from a friend some time ago. I don't know who originated it, but it works: # { for (i = 1; i < (80 - length($0)) / 2; i++) printf("%s"," ") print $0 } -- Bob Howell | Email: howell@solbourne.com Solbourne Computer, Inc. | howell%stan@boulder.colorado.edu 77 S. Bedford St., Suite 230, | ...!{sun,boulder,nbires}!stan!howell Burlington, MA 01803 | Voice: (617) 273-3313 - Fax: (617) 270-0172