ubformat – a simple text formatter


ubformat -[c# l* o# p* w# #] <files>


This utility is similar to nroff but much simpler. Its advantages are that it is small and fast and by using command line options it can format small amounts of text without using dot commands. This is particularly useful for the vi “!” command. e.g. To centre 2 lines and justify the rest of a marked text section in 6O character wide lines use the following keystrokes in vi:

!.+2 ubformat -c2-w6O

The actions of ubformat can be controlled by a simple set of ‘.’ (dot) commands. Unless otherwise directed, ubformat will justify paragraphs to lines 6O characters long. Dot commands are lines in the text that start with a ‘.’.

<P> <TABLE WIDTH=”100%” BGCOLOR=”#000000″> <CAPTION>DOT COMMANDS</CAPTION> <TR><TD> <TABLE WIDTH=”100%” BGCOLOR=”#FFFFFF”> <TR> <TH>COMMAND</TH> <TH>DESCRIPTION</TH> </TR> <TR> <TD>bl n</TD> <TD>print n blank lines (*line spacing)</TD> </TR> <TR> <TD>br</TD> <TD>break to a new line</TD> </TR> <TR> <TD>ce n</TD> <TD>centre next n lines</TD> </TR> <TR> <TD>fi</TD> <TD>start filling output</TD> </TR> <TR> <TD>fo n</TD> <TD>next n lines are footer</TD> </TR> <TR> <TD>in n</TD> <TD>indent n characters</TD> </TR> <TR> <TD>he n</TD> <TD>next n lines are header</TD> </TR> <TR> <TD>lb n t</TD> <TD>label at column n with text t</TD> </TR> <TR> <TD>ll n</TD> <TD>line lenth n characters</TD> </TR> <TR> <TD>ma xx</TD> <TD>define macro xx</TD> </TR> <TR> <TD>me</TD> <TD>end macro definition</TD> </TR> <TR> <TD>nf</TD> <TD>stop filling output</TD> </TR> <TR> <TD>np</TD> <TD>new page</TD> </TR> <TR> <TD>pa</TD> <TD>new paragraph</TD> </TR> <TR> <TD>pc t</TD> <TD>printer characteristic</TD> </TR> <TR> <TD>pn n</TD> <TD>set page number to n</TD> </TR> <TR> <TD>re f</TD> <TD>read input from file f</TD> </TR> <TR> <TD>sp n</TD> <TD>set line spacing to n</TD> </TR> </TABLE> </TD></TR> </TABLE> <P> <TABLE WIDTH=”100%” BGCOLOR=”#000000″> <CAPTION>COMMAND LINE OPTIONS</CAPTION> <TR><TD> <TABLE WIDTH=”100%” BGCOLOR=”#FFFFFF”> <TR> <TH>OPTION</TH> <TH>DESCRIPTION</TH> </TR> <TR> <TD>-c number</TD> <TD>Centre the next number of text lines.</TD> </TR> <TR> <TD>-I characters</TD> <TD>characters is characters to be ignored/placed at the beginning of each line.</TD> </TR> <TR> <TD>-o number</TD> <TD>Offset number characters from left margin.</TD> </TR> <TR> <TD>-w width</TD> <TD>Set the width of a line to width character position (default is 6O).</TD> </TR> <TR> <TD>-number</TD> <TD>Set the length of a page to number lines (default is 66).</TD> </TR> </TABLE> </TD></TR> </TABLE> <P> <h2>EXAMPLE</h2> To centre lines which start with a ‘#’ character <PRE>ubformat -c2 -I# filename</PRE>