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