There are good reasons to have long lines in Emacs. First, long lines are automatically wrapped according to the width of the Emacs window. Second, Emacs' incremental search does not find occurrences that span multiple lines. For example, "word1 word2" is not found if a line-break separates the two words.

This would, in particular, be useful if one reads a sentence in a PDF file and if one wants to find the same sentence in the corresponding LaTeX file. One can, of course, format every paragraph of the LaTeX file as a single line to circumvent the problem.

However, using Emacs with long lines is usually cumbersome because the Ctrl+n and Ctrl+p keys (or the arrow keys) jump to the next physical line of the file, not to the next line on screen.

Fortunately, Emacs 23 provides visual-line-mode for this. If visual-line-mode is activated Ctrl+n, Ctrl+p or the arrow keys act on screen lines instead of physical lines. Moreover, the correct line and column number is reported in the mode line and lines are visually wrapped at word boundaries.

Because I do not want visual-line-mode globally, I use it locally in my LaTeX files by prefixing them with:

% -*- mode:latex ; mode:latex-math ; mode:visual-line ; fill-column: 1000000 -*-

© 2010 René van Bevern. Last modified 2010-07-29.