Sometimes, you may come across “unfilled” text files, which Emacs normally displays as a bunch of extremely long lines. Comfortably reading and editing such files normally requires “word wrap”, a feature that breaks up each long text line into multiple screen lines in a readable manner—by putting the breaks at word boundaries. Many text editors, such as those built into many web browsers, perform word wrapping by default.
There are two different minor modes in Emacs that perform word wrapping. The first is Visual Line mode, which does it by altering the behavior of screen line continuation. See Visual Line Mode, for information about Visual Line mode.
Instead of using Visual Line mode, you can use a minor mode called Long Lines mode. Long Lines mode wraps lines by inserting or deleting soft newlines as you type (see Hard and Soft Newlines). These soft newlines won't show up when you save the buffer into a file, or when you copy the text into the kill ring, clipboard, or a register. Unlike Visual Line mode, Lone Lines mode breaks long lines at the fill column (see Fill Commands), rather than the right window edge. To enable Long Lines mode, type M-x longlines-mode. If the text is full of long lines, this also immediately “wraps” them all.
The word wrap performed by Long Lines mode is not the same as ordinary filling (see Fill Commands). It does not contract multiple spaces into a single space, recognize fill prefixes (see Fill Prefix), or perform adaptive filling (see Adaptive Fill). The reason for this is that a wrapped line is still, conceptually, a single line. Each soft newline is equivalent to exactly one space in that long line, and vice versa. However, you can still call filling functions such as M-q, and these will work as expected, inserting soft newlines that won't show up on disk or when the text is copied. You can even rely entirely on the normal fill commands by turning off automatic line wrapping, with C-u M-x longlines-auto-wrap. To turn automatic line wrapping back on, type M-x longlines-auto-wrap.
Type RET to insert a hard newline, one which automatic refilling will not remove. If you want to see where all the hard newlines are, type M-x longlines-show-hard-newlines. This will mark each hard newline with a special symbol. The same command with a prefix argument turns this display off.
Long Lines mode does not change normal text files that are already
filled, since the existing newlines are considered hard newlines.
Before Long Lines can do anything, you need to transform each
paragraph into a long line. One way is to set fill-column to a
large number (⁖, C-u 9999 C-x f), re-fill all the paragraphs,
and then set fill-column back to its original value.