NFMT

Section: User Commands (1)
Updated: 8 July 1992
Index Return to Main Contents
 

NAME

nfmt - simple optimal text formatter  

SYNOPSIS

nfmt [ -cs ] [ -width ] [ -p prefix ] [ inputfile... ]  

DESCRIPTION

nfmt is a simple text formatter, which is very similar to the BSD program fmt(1). However nfmt uses a best-fit line breaking algorithm, by a simple version of "Breaking Paragraphs into Lines", Donald E. Knuth and Michael F. Plass, "Software--Practice and Experience" 11 (1981) 1119-1184. nfmt (just like fmt ) fills and joins lines to produce output lines of (up to) the number of characters specified in the -width option. The default width is 75. nfmt concatenates the inputfiles listed as arguments. If none are given, nfmt formats text from the standard input.

Blank lines are preserved in the output, as is the spacing between words. Tabs are expanded on input and re-introduced on output (unlike fmt?). Indentation is preserved in the output, and input lines with differing indentation are not joined (unless -c is used).

nfmt can also be used as an in-line text filter for vi(1); the vi command:

!}nfmt

reformats the text between the cursor location and the end of the paragraph. nfmt prefers breaking lines at the end of a sentence, and tries to avoid line breaks after the first word of a sentence or before the last word of a sentence. works based on the following definitions: A sentence break defined as either the end of a paragraph or a word ending in [.?!], possibly followed by ) or ], followed by a word beginning with a capital.  

OPTIONS

-c
Crown margin mode. Preserve the indentation of the first two lines within a paragraph, and align the left margin of each subsequent line with that of the second line. This is useful for tagged paragraphs. The indentation of the first line of a paragraph must be different from the indentation of the second. Subsequent lines must have the same indentation as the second line.
-s
Split lines only. Do not join short lines to form longer ones. This prevents sample lines of code, and other such ``formatted'' text, from being unduly combined.
-width
Fill output lines to up to width columns (default 75). nfmt prefers to make lines about 7% shorter, to give it room to balance line lengths.
-p prefix
Only lines beginning with the prefix (possibly preceded by white space) are re-arranged; the prefix (with any preceding white space) is stripped for the formatting and re-attached to each formatted output line. For example,

formats C comments laid out in the normal way, leaving the code unchanged. The -p option may also be combined with the other options.
 

BUGS

Very long paragraphs silently break nfmt's builtin limits. When the available space is full, nfmt formats what it has so far, chooses a low cost line break near the end and flushes the paragraph to there. There is little cost in either time or quality of output. The crown mode is incompatible with that of fmt(1). nfmt obeys the description in fmt(1) mamual: Indentation is preserved in the output, and input lines with differing indentation are not joined (unless -c is used). fmt(1) does not.  

SEE ALSO

fmt(1), fmt_mail(1), mail(1), nroff(1), vi(1)  

AUTHOR

Please send bug reports and suggestions to the author.

Ross Paterson <rap@doc.ic.ac.uk>

Local installation by Yossi Gil <yogi@cs.ubc.ca>


 

Index

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
BUGS
SEE ALSO
AUTHOR

This document was created by man2html, using the manual pages.
Time: 02:18:36 GMT, February 13, 2022