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