xref: /freebsd/usr.bin/fmt/fmt.1 (revision 17d6c636720d00f77e5d098daf4c278f89d84f7b)
1.\" Copyright (c) 1980, 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     @(#)fmt.1	8.1 (Berkeley) 6/6/93
33.\" $FreeBSD$
34.\"
35.\" Modified by Gareth McCaughan to describe the new version of `fmt'
36.\" rather than the old one.
37.Dd June 25, 2000
38.Dt FMT 1
39.Os
40.Sh NAME
41.Nm fmt
42.Nd simple text formatter
43.Sh SYNOPSIS
44.Nm fmt
45.Op Fl cmps
46.Op Fl d Ar chars
47.Op Fl l Ar num
48.Op Fl t Ar num
49.Op Ar goal Oo Ar maximum Oc | Fl Ns Ar width | Fl w Ar width
50.Op Ar
51.Sh DESCRIPTION
52.Nm
53is a simple text formatter which reads the concatenation of input
54files (or standard input if none are given) and produces on standard
55output a version of its input with lines as close to the
56.Ar goal
57length
58as possible without exceeding the
59.Ar maximum .
60The
61.Ar goal
62length defaults
63to 65 and the
64.Ar maximum
65to 10 more than the
66.Ar goal
67length.
68Alternatively, a single
69.Ar width
70parameter can be specified either by prepending a hyphen to it or by using
71.Fl w .
72For example,
73.Dq Li fmt -w 72 ,
74.Dq Li fmt -72 ,
75and
76.Dq Li fmt 72 72
77all produce identical output.
78The spacing at the beginning of the input lines is preserved in the output,
79as are blank lines and interword spacing.
80Lines are joined or split only at white space; that is, words are never
81joined or hyphenated.
82.Pp
83The options are as follows:
84.Bl -tag -width indent
85.It Fl c
86Center the text, line by line.
87In this case, most of the other
88options are ignored; no splitting or joining of lines is done.
89.It Fl m
90Try to format mail header lines contained in the input sensibly.
91.It Fl p
92Allow indented paragraphs.
93Without the
94.Fl p
95flag, any change in the amount of whitespace at the start of a line
96results in a new paragraph being begun.
97.It Fl s
98Collapse whitespace inside lines, so that multiple whitespace
99characters are turned into a single space.
100(Or, at the end of a
101sentence, a double space.)
102.It Fl d Ar chars
103Treat the
104.Ar chars
105(and no others) as sentence-ending characters.
106By default the
107sentence-ending characters are full stop
108.Pq Ql \&. ,
109question mark
110.Pq Ql \&?
111and exclamation mark
112.Pq Ql \&! .
113Remember that some characters may need to be
114escaped to protect them from your shell.
115.It Fl l Ar number
116Replace multiple spaces with tabs at the start of each output
117line, if possible.
118Each
119.Ar number
120spaces will be replaced with one tab.
121The default is 8.
122If
123.Ar number
124is 0, spaces are preserved.
125.It Fl t Ar number
126Assume that the input files' tabs assume
127.Ar number
128spaces per tab stop.
129The default is 8.
130.El
131.Pp
132.Nm
133is meant to format mail messages prior to sending, but may also be useful
134for other simple tasks.
135For instance,
136within visual mode of the
137.Xr ex 1
138editor (e.g.,
139.Xr vi 1 )
140the command
141.Pp
142.Dl \&!}fmt
143.Pp
144will reformat a paragraph,
145evening the lines.
146.Sh SEE ALSO
147.Xr mail 1 ,
148.Xr nroff 1
149.Sh HISTORY
150The
151.Nm
152command appeared in
153.Bx 3 .
154.Pp
155The version described herein is a complete rewrite and appeared in
156.Fx 4.4 .
157.Sh AUTHORS
158.An Kurt Shoens
159.An Liz Allen
160(added
161.Ar goal
162length concept)
163.An Gareth McCaughan
164.Sh BUGS
165The program was designed to be simple and fast \- for more complex
166operations, the standard text processors are likely to be more appropriate.
167.Pp
168When the first line of an indented paragraph is very long (more than
169about twice the goal length), the indentation in the output can be
170wrong.
171.Pp
172.Nm
173is not infallible in guessing what lines are mail headers and what
174lines are not.
175