xref: /freebsd/usr.bin/fmt/fmt.1 (revision 9336e0699bda8a301cd2bfa37106b6ec5e32012e)
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 August 2, 2004
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 cmnps
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
52The
53.Nm
54utility is a simple text formatter which reads the concatenation of input
55files (or standard input if none are given) and produces on standard
56output a version of its input with lines as close to the
57.Ar goal
58length
59as possible without exceeding the
60.Ar maximum .
61The
62.Ar goal
63length defaults
64to 65 and the
65.Ar maximum
66to 10 more than the
67.Ar goal
68length.
69Alternatively, a single
70.Ar width
71parameter can be specified either by prepending a hyphen to it or by using
72.Fl w .
73For example,
74.Dq Li fmt -w 72 ,
75.Dq Li fmt -72 ,
76and
77.Dq Li fmt 72 72
78all produce identical output.
79The spacing at the beginning of the input lines is preserved in the output,
80as are blank lines and interword spacing.
81Lines are joined or split only at white space; that is, words are never
82joined or hyphenated.
83.Pp
84The options are as follows:
85.Bl -tag -width indent
86.It Fl c
87Center the text, line by line.
88In this case, most of the other
89options are ignored; no splitting or joining of lines is done.
90.It Fl m
91Try to format mail header lines contained in the input sensibly.
92.It Fl n
93Format lines beginning with a
94.Ql \&.
95(dot) character.
96Normally,
97.Nm
98does not fill these lines, for compatibility with
99.Xr nroff 1 .
100.It Fl p
101Allow indented paragraphs.
102Without the
103.Fl p
104flag, any change in the amount of whitespace at the start of a line
105results in a new paragraph being begun.
106.It Fl s
107Collapse whitespace inside lines, so that multiple whitespace
108characters are turned into a single space.
109(Or, at the end of a
110sentence, a double space.)
111.It Fl d Ar chars
112Treat the
113.Ar chars
114(and no others) as sentence-ending characters.
115By default the
116sentence-ending characters are full stop
117.Pq Ql \&. ,
118question mark
119.Pq Ql \&?
120and exclamation mark
121.Pq Ql \&! .
122Remember that some characters may need to be
123escaped to protect them from your shell.
124.It Fl l Ar number
125Replace multiple spaces with tabs at the start of each output
126line, if possible.
127Each
128.Ar number
129spaces will be replaced with one tab.
130The default is 8.
131If
132.Ar number
133is 0, spaces are preserved.
134.It Fl t Ar number
135Assume that the input files' tabs assume
136.Ar number
137spaces per tab stop.
138The default is 8.
139.El
140.Pp
141The
142.Nm
143utility
144is meant to format mail messages prior to sending, but may also be useful
145for other simple tasks.
146For instance,
147within visual mode of the
148.Xr ex 1
149editor (e.g.,
150.Xr vi 1 )
151the command
152.Pp
153.Dl \&!}fmt
154.Pp
155will reformat a paragraph,
156evening the lines.
157.Sh ENVIRONMENT
158The
159.Ev LANG , LC_ALL
160and
161.Ev LC_CTYPE
162environment variables affect the execution of
163.Nm
164as described in
165.Xr environ 7 .
166.Sh SEE ALSO
167.Xr fold 1 ,
168.Xr mail 1 ,
169.Xr nroff 1
170.Sh HISTORY
171The
172.Nm
173command appeared in
174.Bx 3 .
175.Pp
176The version described herein is a complete rewrite and appeared in
177.Fx 4.4 .
178.Sh AUTHORS
179.An Kurt Shoens
180.An Liz Allen
181(added
182.Ar goal
183length concept)
184.An Gareth McCaughan
185.Sh BUGS
186The program was designed to be simple and fast \- for more complex
187operations, the standard text processors are likely to be more appropriate.
188.Pp
189When the first line of an indented paragraph is very long (more than
190about twice the goal length), the indentation in the output can be
191wrong.
192.Pp
193The
194.Nm
195utility is not infallible in guessing what lines are mail headers and what
196lines are not.
197