fmt - simple text formatter
fmt [-cmnps] [-d chars] [-l num] [-t num] [goal [maximum] |
-width | -w
width] [file ...]
fmt is a simple text formatter which reads the concatenation
files (or standard input if none are given) and produces on
a version of its input with lines as close to the goal
length as possible
without exceeding the maximum. The goal length defaults to 65 and
the maximum to 10 more than the goal length. Alternatively,
width parameter can be specified either by prepending a hyphen to it or
by using -w. For example, ``fmt -w 72'', ``fmt -72'', and
``fmt 72 72''
all produce identical output. The spacing at the beginning
of the input
lines is preserved in the output, as are blank lines and interword spacing.
Lines are joined or split only at white space; that
is, words are
never joined or hyphenated.
The options are as follows:
-c Center the text, line by line. In this case, most
of the other
options are ignored; no splitting or joining of
lines is done.
-m Try to format mail header lines contained in the input sensibly.
-n Format lines beginning with a `.' (dot) character.
does not fill these lines, for compatibility with
-p Allow indented paragraphs. Without the -p flag, any
the amount of whitespace at the start of a line results in a new
paragraph being begun.
-s Collapse whitespace inside lines, so that multiple
characters are turned into a single space. (Or, at
the end of a
sentence, a double space.)
Treat the chars (and no others) as sentence-ending
By default the sentence-ending characters are full
question mark (`?') and exclamation mark (`!'). Remember that
some characters may need to be escaped to protect
them from your
Replace multiple spaces with tabs at the start of
line, if possible. number spaces will be replaced
with one tab.
Assume that the input files' tabs assume number
spaces per tab
stop. The default is 8.
fmt is meant to format mail messages prior to sending, but
may also be
useful for other simple tasks. For instance, within visual
mode of the
ex(1) editor (e.g., vi(1)) the command
will reformat a paragraph, evening the lines.
mail(1), nroff(1), troff(1)
The fmt command appeared in 3BSD.
The version described herein is a complete rewrite and appeared in OpenBSD
Liz Allen (added goal length concept)
Gareth McCaughan (wrote this version)
The program was designed to be simple and fast - for more
the standard text processors are likely to be more
When the first line of an indented paragraph is very long
about twice the goal length), the indentation in the output
can be wrong.
fmt is not infallible in guessing what lines are mail headers and what
lines are not.
OpenBSD 3.6 June 6, 1993
[ Back ]