Emacs Line Wrapping

Line breaking in Emacs is a complicated thing. By default the line just stops at the window edge and you have to scroll right to see some or all of the truncated part. This is called truncating long lines. That’s probably what you want for the programming modes but a case can be made for just breaking the line at the window edge and wrapping the rest to the next displayed line. Emacs calls this wrapping at the window edge. A downside to this method is that a word can be split in the middle if it straddles the window edge.

You can already see a problem with just those two behaviors. What do we call the two “lines” in the second method? It’s actually a single line but it’s displayed as two. Some of the commands that operate on lines treat it as two lines and some treat it as one so there can be a lot of confusion.

But, of course, there’s more. Visual line mode is like wrapping at the window edge but takes care to break the line at a word boundary. That’s probably what you want for writing prose (as opposed to code). It’s the mode I’m using to write this post.

Finally, there’s a fourth mode, autofill mode, that is like visual line mode but inserts actual line breaks at the places the line is split. That makes what you see on the screen correspond to the actual text file.

As I said above, all of this can be a bit confusing. Emacs Elements has a very nice video that explains the terminology for talking about the lines and demonstrates the four modes. It’s 12 minutes, 21 seconds long so you’ll have to set some time aside but it’s a good way to get a handle on this confusing Emacs aspect.

This entry was posted in General and tagged . Bookmark the permalink.