xref: /openbsd/usr.bin/fmt/fmt.1 (revision 404b540a)
1.\" $OpenBSD: fmt.1,v 1.21 2007/05/31 19:20:10 jmc Exp $
2.\"
3.\" Copyright (c) 1980, 1990, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"     @(#)fmt.1	8.1 (Berkeley) 6/6/93
31.\"
32.Dd $Mdocdate: May 31 2007 $
33.Dt FMT 1
34.Os
35.Sh NAME
36.Nm fmt
37.Nd simple text formatter
38.Sh SYNOPSIS
39.Nm fmt
40.Op Fl cmnps
41.Op Fl d Ar chars
42.Op Fl l Ar number
43.Op Fl t Ar number
44.br
45.Oo
46.Ar goal
47.Oo Ar maximum Oc \*(Ba
48.Fl Ns Ar width \*(Ba
49.Fl w Ar width
50.Oc
51.Op Ar
52.Sh DESCRIPTION
53.Nm
54is a simple text formatter which reads the concatenation of input
55files (or standard input if none are given) and produces on standard
56output a version of its input with lines as close to the
57.Ar goal
58length
59as possible without exceeding the
60.Ar maximum .
61The
62.Ar goal
63length defaults
64to 65 and the
65.Ar maximum
66to 10 more than the
67.Ar goal
68length.
69.Pp
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 fmt -w 72 ,
76.Dq fmt -72 ,
77and
78.Dq 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 Ds
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 d Ar chars
92Treat
93.Ar chars
94(and no others) as sentence-ending characters.
95By default the
96sentence-ending characters are full stop
97.Pq Ql \&. ,
98question mark
99.Pq Ql \&? ,
100and exclamation mark
101.Pq Ql \&! .
102Remember that some characters may need to be
103escaped to protect them from the shell.
104.It Fl l Ar number
105Replace multiple spaces with tabs at the start of each output
106line, if possible.
107.Ar number
108spaces will be replaced with one tab.
109.It Fl m
110Try to format mail header lines contained in the input sensibly.
111.It Fl n
112Format lines beginning with a
113.Ql \&.
114(dot) character.
115Normally,
116.Nm
117does not fill these lines, for compatibility with
118.Xr troff 1
119and
120.Xr nroff 1 .
121.It Fl p
122Allow indented paragraphs.
123Without the
124.Fl p
125flag, any change in the amount of whitespace at the start of a line
126results in a new paragraph being begun.
127.It Fl s
128Collapse whitespace inside lines, so that multiple whitespace
129characters are turned into a single space
130(or, at the end of a
131sentence, a double space).
132.It Fl t Ar number
133Assume that the input files' tabs assume
134.Ar number
135spaces per tab stop.
136The default is 8.
137.El
138.Pp
139.Nm
140is meant to format mail messages prior to sending, but may also be useful
141for other simple tasks.
142For instance,
143within an editor such as
144.Xr vi 1 ,
145the following command
146will reformat a paragraph,
147evening the lines:
148.Pp
149.Dl !}fmt
150.Sh SEE ALSO
151.Xr indent 1 ,
152.Xr mail 1 ,
153.Xr nroff 1 ,
154.Xr vi 1
155.Sh HISTORY
156The
157.Nm
158command appeared in
159.Bx 3 .
160.Pp
161The version described herein is a complete rewrite and appeared in
162.Ox 2.4 .
163.Sh AUTHORS
164.An Kurt Shoens
165.An Liz Allen
166(added goal length concept)
167.An Gareth McCaughan
168(wrote this version)
169.Sh BUGS
170The program was designed to be simple and fast \(en for more complex
171operations, the standard text processors are likely to be more appropriate.
172.Pp
173When the first line of an indented paragraph is very long (more than
174about twice the goal length), the indentation in the output can be
175wrong.
176.Pp
177.Nm
178is not infallible in guessing what lines are mail headers and what
179lines are not.
180