fmt - simple optimal text formatter
This manual page documents the GNU version of
is a simple text formatter that
fills and joins lines to produce output lines of (up to) the specified
line breaking algorithm, by a simple version of
\*(lqBreaking Paragraphs into Lines\*(rq,
Donald E. Knuth and Michael F. Plass,
Software---Practice and Experience
listed as arguments. If none are given,
formats text from the standard input.
Blank lines are preserved in the output, as is the spacing between words
In contrast to BSD
tabs are expanded on input and re-introduced on output.
Indentation is preserved in the output, and input lines with differing
indentation are not joined (unless
Note that although the BSD
manual also states this,
the BSD version does in fact join following lines with less indentation.
prefers breaking lines at the end of a sentence,
and tries to avoid line breaks after the first word of a sentence
or before the last word of a sentence.
A sentence break is defined as either the end of a paragraph or a word ending
in [.?!], followed by two spaces or end of line,
ignoring any intervening parentheses or quotes.
Crown margin mode.
Preserve the indentation of the first two lines within a paragraph, and
align the left margin of each subsequent line with that of the second line.
Tagged paragraph mode:
just like crown mode, except that
the indentation of the first line of a paragraph must be different
from the indentation of the second.
Otherwise the first line is treated as a one-line paragraph.
Split lines only. Do not join short lines to form longer ones.
This prevents sample lines of code, and other such \*(lqformatted\*(rq text,
from being unduly combined.
Reduce spacing between words to one space, except at the end of a sentence
-width, -w width, --width=width
Fill output lines to up to
prefers to make lines about 7% shorter, to give it room to balance line
Only lines beginning with the prefix (possibly preceded by white
space) are re-arranged; the prefix (with any preceding white
space) is stripped for the formatting and re-attached to each
formatted output line.
One use is to format certain kinds of program comments,
while leaving the code unchanged.
Print a usage message and exit with a status code indicating success.
Print version information on standard output then exit.