To wrap or not to wrap


First of all, if you don’t know what a line wrap is, but you’re constantly using text editors you’re going to want to know. So lets ask Wikipedia,

In text display, line wrap is the feature of continuing on a new line when a line is full, such that each line fits in the viewable window, allowing text to be read from top to bottom without any horizontal scrolling.

Additionally, you can do a soft wrap, which is the break resulting from a line wrap, or a hard wrap as an intentional break–creating a new paragraph. Most modern text editors soft wrap lines by default, that is they adjust the line lengths automatically with adjustments to the width of the user’s window.

While in most situations staying with soft wrapping is not an inconvenience, hard wrapping might just be what you need under several special circumstances. Computer programmers actually make use of hard wrapping on a daily basis, because when working with text editors for checking/writing code you really need your lines perfectly wrapped and properly indented to check your code or for spotting errors.

The actual issue comes from the fact that when compiling, you might get an error pointing to line 87 of your code. If line 87 is soft-wrapped with who knows what other code. It could be truly cumbersome to find the error. Now, the same applies for tex files. And it is really easy to mess up a tex file, especially because you’re actually writing a document (article, presentation, etc.) with–most likely–soft-wrapped paragraphs, as opposed to programming.

If you consider another situation, such as in version control. When carrying out a diff command, it is almost impossible to spot a typo with a soft-wrapped paragraph. Furthermore, fixing this single typo will be considered as a change in whole line (is this what you really want?). The same happens when running a grep command. There’s another typical situation where you wish the editor would best hard wrap. Some mail clients don’t wrap well (or don’t wrap at all) when you’re forwarding or replying to a message. The consequence is that the recipient has to scroll horizontally to what seems and endless line to read the quoted message.

However, not everything is great with hard wrapping. Hard-wrapped paragraphs look nice until you start to edit them. If you hard wrap again, you end up with a much more lines changed in the diff than you originally intended.

So, do I soft wrap or hard wrap?

On the one hand, if you haven’t had any of the problems I’ve mentioned, and you really don’t know what your regular text editor is doing, keep doing what works for you. On the other, there seems to be reasonably compromise as suggested by Will Robertson on stackoverflow. He wraps by sentences,

  • Small changes are comparatively easy to spot in a diff.
  • No re-flowing of text, only changes to, insertions of, or removal of single lines.

Looks a bit weird when you first look at it, but is the only compromise I’ve seen that addresses the two problems of soft and hard wrapping.

If you want to try it, or had a similar issue with wrapping, leave a comment. Who knows, this approach could probably make us write shorter sentences, which in general is much better than really long sentences that hardly let you catch your breath.

Advertisements

One thought on “To wrap or not to wrap

  1. Pingback: Writing the PhD thesis: the tools Part I | Between the Candle and the Star

If you liked this post please leave a comment or consider subscribing.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s