FMT

NAME
SYNOPSIS
DESCRIPTION

NAME

fmt - simple optimal text formatter

SYNOPSIS

fmt [-cstu] [-width] [-w width] [-p prefix] [--crown-margin] [--split-only] [--tagged-paragraph] [--uniform-spacing] [--width=width] [--prefix=prefix] [--help] [--version] [file ...]

DESCRIPTION

This documentation is no longer being maintained and may be inaccurate or incomplete. The Texinfo documentation is now the authoritative source.

This manual page documents the GNU version of fmt. fmt is a simple text formatter that fills and joins lines to produce output lines of (up to) the specified width (default 75). However fmt uses a best-fit line breaking algorithm, by a simple version of “Breaking Paragraphs into Lines”, Donald E. Knuth and Michael F. Plass, Software—Practice and Experience 11 (1981) 1119-1184.

fmt concatenates the files listed as arguments. If none are given, fmt formats text from the standard input.

Blank lines are preserved in the output, as is the spacing between words (unless -u is used). In contrast to BSD fmt, 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 -c or -t is used). Note that although the BSD fmt manual also states this, the BSD version does in fact join following lines with less indentation.

fmt 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.

OPTIONS
-c, --crown-margin

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.

-t, --tagged-paragraph

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.

-s, --split-only

Split lines only. Do not join short lines to form longer ones. This prevents sample lines of code, and other such “formatted” text, from being unduly combined.

-u, --uniform-spacing

Uniform spacing. Reduce spacing between words to one space, except at the end of a sentence (two spaces).

-width, -w width, --width=width

Fill output lines to up to width columns (default 75). fmt prefers to make lines about 7% shorter, to give it room to balance line lengths.

-p, --prefix=prefix

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.

--help

Print a usage message and exit with a status code indicating success.

--version

Print version information on standard output then exit.