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