Emacs Advent Calendar 18: Line Breaking

Fri 2015-12-18

When a (logical) line is wider than an Emacs window it is wrapped around into the next (screen) line. There are alternatives to this behavior.

When line truncation is enabled with M-x toggle-truncate-lines, the remainder of a line is cut at the right window border. Moving point to the right in such a line scrolls the buffer horizontally.

To get line wrapping, but only on word boundaries, enable Visual Line Mode with M-x visual-line-mode. Here the commands C-a, C-e and C-k will operate on screen lines and not on logical lines. The line breaks inserted by Visual Line Mode will not be saved to the final file.

Alternatively, auto-fill-mode can be enabled. Here, hard line breaks will be inserted at word boundaries so that no text will be wider than the current value of fill-column, usually 70 characters.

Full documentation on this can be found in sections 14.21 (Line Truncation), 14.22 (Visual Line Mode) and 25.5.1 (Auto Fill Mode).


This text by Ludger Sandig is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.