Note: Long Lines is obsolete and has been replaced by VisualLineMode.

Long Lines is a minor mode that helps you edit text files that have long lines.

Lines are separated by line ending characters. When you hit the Return key (‘RET’) or the equivalent, a line ending is inserted. A line ending is also called a hard return.

Long Lines mode visually wraps long lines, to fill text and prevent lines from running off the screen. This wrapping is a display effect. It works by inserting line-ending characters temporarily. These visual line separations are called soft returns. Soft returns are removed when text is copied to the kill ring or the buffer is saved to disk.

This means that, ultimately, the text in a file you edit is changed only by hard returns (the returns that you insert manually), not by soft returns (which are inserted temporarily for visual wrapping).

GnuEmacs 22 and later come with Long Lines mode. For other versions of Emacs, you can download it here: Lisp:longlines.el. (Do not take the version of longlines.el from Emacs CVS and dump it into an older Emacs version; it’s not compatible. The version of longlines.el in the ElispArea (Lisp:longlines.el) is maintained to be compatible with older Emacs versions and with XEmacs.)

By default, soft returns are automatically inserted as you edit, to keep your text wrapped. If you do not want this effect, set ‘longlines-auto-wrap’ to ‘nil’. You can still type ‘M-q’, or use any of the other fill commands, to fill text using soft returns (see FillParagraph.)

If you invoke command ‘longlines-show-hard-newlines’ or set variable ‘longlines-show-hard-newlines’ to non-‘nil’, then hard returns are marked with a glyph. This makes typing errors easier to spot.

Long Lines mode does not lengthen short lines. It does not remove line endings (hard returns); it only (visually) wraps long lines.

If you want to remove hard returns and then let Long Lines mode handle line wrapping, you can do this:

  1. Use ‘C-u 99999 C-x f’ to set variable ‘fill-column’ to 99999.
  2. Use command ‘fill-region’ to fill all paragraphs in the region. Or use ‘M-q’ (‘fill-paragraph’) on individual paragraphs to fill them. See also commands ‘fill-individual-paragraphs’, ‘fill-nonuniform-paragraphs’, and ‘fill-region-as-paragraph’.

If ‘longlines-wrap-follows-window-size’ is non-‘nil’, then Long Lines mode uses the window size as the wrap limit, instead of ‘fill-column’.

Long Lines mode was originally written by AlexSchroeder and KaiGrossjohann. The current maintainer is ChongYidong.

If you find a bug in Long Lines mode, email ChongYidong. Do not write about it on this page (it won’t be read by ChongYidong). ChongYidong’s email address is in longlines.el.