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