Hard vs. Soft Line Wrap

When editing text, I have been using Vim so far. My text documents were either Markdown, reStructuredText or LaTeX. All of them are just source code in some sense, the output format HTML or a PDF in a browser. Single line breaks do not matter in either format, it takes a blank line in between to separate paragraphs. Therefore one has the freedom to insert line breaks within a paragraph at will without it meaning anything semantically.

For a long time I have used hard line wrap. This means that I let my editor insert a line break after 79 characters per line, limiting the line length to 80 characters (including the line break \n). The alternative is soft line wrap where the editor does not insert line breaks into the source code but just virtually wraps the lines for display such that it fits. This latter approach is what one is used from word processors like Microsoft Word or LibreOffice Writer. Also it is used in virtually all web forms.

The soft line wrap looks like the following picture in an editor. You can see the line numbers and as such each paragraph only has a single line number. The text is wrapped in a soft fashion that is just done to fit the window for viewing.

The alternative is breaking the lines by inserting a line break, then it looks like the following:

There one can see the line numbers, each line has its own number and therefore they are broken into multiple lines in the source code.

I have preferred the hard line wrap due to advantages in certain areas, but starting to doubt that this is the right approach for prose and blog posts. Let's take a look at different aspects and compare them.

Window sizes

One argument in favor of hard line wrapping is that text looks really bad when the editor window is too wide. Then you have something like this:

The text has like 120 characters per line, that is hard to read as one increasingly often starts to lose the current line. If you used hard wrap, then it still looks neat:

So I can take a text file with hard line wrap and open it in the dumbest editor in any huge window size and just have it formatted nicely. Markdown is a source code, yet it is meant to be read in its plain form as well. So having a nice format in the source can also be favorable.

But when the window size is insufficient for the fixed text width, it starts to look super ugly:

You see that the lines still have their own line numbers, but they additionally experience soft line wrap on top of hard line wrap. This just looks super bad.

If we had used soft line wrap, it would still look the same:

We see that the advantage of using hard wrap is that presentations where we cannot shrink the width still look decent. But if the width is smaller than we expected (say on a phone) it will be much worse.

It is similar to the reasoning for tabs vs. spaces. I used to be in Team Tabs and argued that now everyone can just adjust the width of the tabs in display and therefore everone has it the way that they want. But these days I'm in Team Spaces because I want that it looks the same on every platform. I don't have to set anything up. With tabs I would need to tell my edtior, git, GitHub and every other tool the width of my tabs.


When editing text in every normal edtior, soft line wrap is just natural. But in Vim the up and down arrow keys (or j and k) move down a physical line in the file, not a virtual line in the display. This can be fixed by using gj and gk instead. Also you can only scroll such that the whole physical line fits onto the screen. If I have long paragraphs, I can only scroll per paragraph.

On the other hand, Vim has the great gq command which lets you just reflow a paragraph. And as one can see in the screenshots, it also knows about say Markdown list constructs and properly wraps them in hard line wrap mode. But in soft line wrap mode it seems to know nothing about that and does not do an intelligent soft wrap. Supposedly there are plugins that help with that.

If you are in any other editor, you will have a harder time keeping the hard line wrap neat. Therefore it is best with these editors to just not bother and use soft line wrap instead.

Basically some of the quirks in Vim make it easier to use hard wrap, which makes it harder for everything else.

Taking differences

I have my source code versioned in git. And also my blog posts as they are just a bunch of Markdown documents. When I do a git diff, it will work line-wise by default. When I have very long lines, the differences will not be usable that easily. When using hard line wrap, it will be easier to spot changes.

Well, unless you have inserted a long word at the beginning of the paragraph and have reflowed the whole thing. Then you see a diff where a lot of lines have changed in a non-trivial way.

One can just use git diff --color-words and see the differences on a word level. If one does that with hard line wrap, it won't give sensible results. So although differences are often quoted as a reason to use hard line wrap, it just does not make that much sense.


When I paste hard wrapped text to somewhere else where hard wrapped is not expected, I have a problem. With text e-mail I am expected to have 72 columns at most. Pasting 80 columns leads to this strange staggering.

GitHub flavored Markdown assumes that even single line breaks are meaningful and preserves them in the output. My hard wrapped text looks very strange on the website then. Either it is not wide enough (on desktop) or looks staggered (on mobile).

There are programs with arcane restrictions. The Postfix software for instance discards all e-mails which have lines longer than 1000 characters. Or LaTeX has a line length limit, which currently is so high that it will never be a problem for reasonable proportioned paragraphs.


Although I have been using hard line wrap for years in all my documents, I will try to switch over to soft line wrap. For programming source code I will stil use hard line wrap, but new blog posts, notes and prose are going to be free.