Wrap Text

Hard wrap at a column, without breaking words.

Hard wrap at a column, without breaking words.

How to use it

  1. Paste the text. Existing paragraph breaks are kept.
  2. Set the column width. 72 for a commit message body, 80 for most other things.
  3. Copy the wrapped text. The longest line is reported, so you can see if a word overran.

When you would use this

Hard wrapping is inserting line breaks at a column so that text reads correctly somewhere that will not wrap it for you: a commit message, a plain text email, a code comment. The only decision in it is what to do with a word longer than the column, and the answer is to leave it alone. A URL or a long identifier broken across two lines cannot be reassembled by the reader and cannot be copied, which is a worse outcome than one line running over. The tool says when that happened so it is not a surprise. Existing line breaks are kept and each line is wrapped independently, so paragraphs stay separate. This hard wraps rather than reflowing: it will not join two short lines into one, because doing so would destroy deliberate line breaks in poetry, addresses and signatures. 72 columns is right for a git commit body, since git indents by four when displaying one and 80 is the terminal width it has to fit inside. 80 is the safe default everywhere else.

Questions

What happens to a word longer than the column?
It is left whole on its own line, and the tool says a word overran. Breaking a URL or an identifier in half is worse than one long line, because the reader cannot reassemble it and a copy and paste no longer works.
Does it keep my paragraphs?
Yes. Existing line breaks are preserved and each line is wrapped on its own, so a blank line between paragraphs stays a blank line. It hard wraps rather than reflowing, which means it will not join two short lines into one.
What width should I use?
72 for the body of a git commit message, which leaves room for the four space indent git adds when it displays one. 80 is the traditional terminal width and a safe default for plain text email and code comments.