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