xref: /openbsd/usr.bin/fmt/fmt.1 (revision 5af055cd)
1.\" $OpenBSD: fmt.1,v 1.29 2015/12/15 17:48:16 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: December 15 2015 $
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.Op Ar goal Oo Ar maximum Oc | Fl Ar width | Fl w Ar width
45.Op Ar
46.Sh DESCRIPTION
47.Nm
48is a simple text formatter which reads the concatenation of input
49files (or standard input if none are given) and produces on standard
50output a version of its input with lines as close to the
51.Ar goal
52length
53as possible without exceeding the
54.Ar maximum .
55The
56.Ar goal
57length defaults
58to 65 and the
59.Ar maximum
60to 10 more than the
61.Ar goal
62length.
63.Pp
64Alternatively, a single
65.Ar width
66parameter can be specified either by prepending a hyphen to it or by using
67.Fl w .
68For example,
69.Dq fmt -w 72 ,
70.Dq fmt -72 ,
71and
72.Dq fmt 72 72
73all produce identical output.
74The spacing at the beginning of the input lines is preserved in the output,
75as are blank lines and interword spacing.
76Lines are joined or split only at white space; that is, words are never
77joined or hyphenated.
78.Pp
79The options are as follows:
80.Bl -tag -width Ds
81.It Fl c
82Center the text, line by line.
83In this case, most of the other
84options are ignored; no splitting or joining of lines is done.
85.It Fl d Ar chars
86Treat
87.Ar chars
88(and no others) as sentence-ending characters.
89By default the
90sentence-ending characters are full stop
91.Pq Ql \&. ,
92question mark
93.Pq Ql \&? ,
94and exclamation mark
95.Pq Ql \&! .
96Remember that some characters may need to be
97escaped to protect them from the shell.
98.It Fl l Ar number
99Replace multiple spaces with tabs at the start of each output
100line, if possible.
101.Ar number
102spaces will be replaced with one tab.
103.It Fl m
104Try to format mail header lines contained in the input sensibly.
105.It Fl n
106Format lines beginning with a
107.Ql \&.
108(dot) character.
109Normally,
110.Nm
111does not fill these lines,
112for compatibility with troff and nroff.
113.It Fl p
114Allow indented paragraphs.
115Without the
116.Fl p
117flag, any change in the amount of whitespace at the start of a line
118results in a new paragraph being begun.
119.It Fl s
120Collapse whitespace inside lines, so that multiple whitespace
121characters are turned into a single space
122(or, at the end of a
123sentence, a double space).
124.It Fl t Ar number
125Assume that the input files' tabs assume
126.Ar number
127spaces per tab stop.
128The default is 8.
129.El
130.Pp
131.Nm
132is meant to format mail messages prior to sending, but may also be useful
133for other simple tasks.
134For instance,
135within an editor such as
136.Xr vi 1 ,
137the following command
138will reformat a paragraph,
139evening the lines:
140.Pp
141.Dl !}fmt
142.Sh ENVIRONMENT
143.Bl -tag -width LC_CTYPE
144.It Ev LC_CTYPE
145The character set
146.Xr locale 1 .
147It is used to decide which byte sequences form characters and what
148their display width is.
149If it is unset or set to
150.Qq C ,
151.Qq POSIX ,
152or an unsupported value, each byte except the tab is assumed
153to represent a character of display width 1.
154.El
155.Sh EXIT STATUS
156.Ex -std
157The latter happens with invalid options, insufficient memory,
158or when an input file is not found or not readable.
159The >0 exit value is the sum of all errors up to a maximum of 127;
160more errors may occur but the counter will only increment to this number.
161.Sh SEE ALSO
162.Xr indent 1 ,
163.Xr mail 1 ,
164.Xr vi 1
165.Sh HISTORY
166The
167.Nm
168command first appeared in
169.Bx 2 .
170.Pp
171The version described herein is a complete rewrite and appeared in
172.Ox 2.4 .
173.Sh AUTHORS
174.An Kurt Shoens
175(July 1978)
176.An Liz Allen
177(added goal length concept)
178.An Gareth McCaughan
179(wrote this version)
180.Sh BUGS
181The program was designed to be simple and fast \(en for more complex
182operations, the standard text processors are likely to be more appropriate.
183.Pp
184When the first line of an indented paragraph is very long (more than
185about twice the goal length), the indentation in the output can be
186wrong.
187.Pp
188.Nm
189is not infallible in guessing what lines are mail headers and what
190lines are not.
191