fmt flags & options

Basic usage

Reflow text to fit within 75 characters (default width).

fmt long_paragraph.txt

-w, --width

Set the maximum line width.

fmt -w 60 document.txt
fmt -w 80 README.txt

-s, --split-only

Split long lines but don't join short ones.

fmt -s -w 72 file.txt

-u, --uniform-spacing

Use one space between words and two after sentences.

fmt -u document.txt

-c, --crown-margin

Preserve the first two lines' indentation, reflow the rest to match the second line.

fmt -c paragraph.txt

-p, --prefix

Only reformat lines beginning with the given prefix.

fmt -p '# ' comments.txt

Pipe usage

Reformat output from other commands.

cat README.md | fmt -w 72
git log --oneline | fmt -w 100