Centering lines in vi
Bob Howell
howell at Soleast.Solbourne.COM
Wed Sep 13 12:38:05 AEST 1989
> 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 at solbourne.com
Solbourne Computer, Inc. | howell%stan at 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
More information about the Comp.unix.questions
mailing list