views:

736

answers:

10

Do you use "hard wrapping" (either yourself or automatically by your editor) by inserting newlines into your source document at a certain line length, or do you write your paragraphs in one continual line and let your editor "soft-wrap" for you?

Also, what editor do you use for this?

Note: I'm interested in how you wrap lines in your TeX source code (.tex file, general prose), not how TeX wraps lines for the final document.

+1  A: 

I tend to do hard-wrapping with TeX, but that's rooted more in my obsession with text formatting than any real gain of efficiency. One major thing that I don't like about soft-wrapping is that it tends (in my opinion, obviously) to make things harder to read by wrapping in semantically-random places.

Paul Morie
+2  A: 

Typically I have my editor insert newlines. That is, I try not to hit the "enter" key for a new line, but when the editor soft-wraps, it actually inserts a newline character.

I use vim to accomplish this, and I don't know if other editors have this feature or how they work. In specific, i use the wrapmargin feature.

I typically try to keep my lines of code (TeX or otherwise) at n-characters long for clarity and consistency. I tend to go with 80 characters, but that is up to you.

More vim-related line-breaking docs:

http://www.vim.org/htmldoc/usr_25.html

http://www.vim.org/htmldoc/options.html#%27textwidth%27

rascher
+1  A: 

I generally let my LaTeX editor softwrap the lines. I think part of it is due to the fact that I had some bad experiences with significant whitespace when I was first learning LaTeX, and part of it is because I don't like heavily-jagged right-margins when I'm editing the text file.

Greg D
+1  A: 

Depending on what os you use, i recommend winedt (windows) and kile (linux). Both of these soft wrap, and there is no need for hard wraps. (That is, i leave my paragraphs as long lines in the source) Latex sorts out line breaks in the output and when i read the source, i use my editor.

The only possible reason to use hard line breaks is to make it easier to find errors in the code (which the compiler indicates by line number) but they are generally not hard to find, if it's mainly text, errors are rare anyway.

second
+3  A: 

I use Emacs (with AUCTeX). After editing or writing a paragraph, I hit M-q to hard-wrap it. It also handles indenting items, and it also formats commented paragraphs. I don't like soft wraps, because they are visually indistinguishable from real newline characters, but behave differently.

Svante
A: 

I work in joe mostly. I from time to time press enter automatically, and if it doesn't look good I press auto-format (ctrl-k j).

Joe has autowrap modes, but I don't even bother.

Marco van de Voort
+1  A: 

Although I would prefer to use soft wrapping I end up using hard wrapping for one practical reason: all of my collaborators do the same. So, when I work on an article with someone it would be a big pain for me to soft wrap while the other person hard wraps. The second reason is that Emacs was until recently able to handle properly on hard wrapping. Emacs 23 which I currently use changes this but it will be a long time before everybody upgrades to 23 so I can sneak soft wrapped texts to them.

The way I actually use hard wrapping is to have auto-fill-mode turned on. Furthermore M-q is bound to LaTeX-fill-paragraph (in the AucTeX mode - but I don't remember if this is a standard binding or one of my bindings - I'm pretty sure it's the latter). Combining these two I manage to keep my TeX source more or less decently formatted.

By the way, I have heard the suggestion to always start a new sentence at the beginning of a line. In other words a period at the end of a sentence should be followed by a hard return. The benefit is that it works well with version control systems since changes to a sentence can remain localized. I think that this is in principle a nice idea but I have not managed to use it because of my obsessive-compulsive usage of M-q.

cefstat
+6  A: 

I recently switched to hard-wrapping per sentence (i.e., newline after sentence end only; one-to-one mapping between lines and sentences) for two reasons:

  • softwrap for a whole paragraph makes typos impossible to spot in version control diffs.
  • hardwrapped paragraphs look nice until you start to edit them, and if you re-flow a hard wrapped paragraph you end up with a whole bunch of lines changed in the diff for a possibly one word change.

Only wrapping per sentence fixes these two problems:

  • 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.

Of course, if you're working collaboratively, the answer is to use whatever the other people are using.

Will Robertson
I also changed to this, and it has made things significantly easier. I think that I'll be doing this everywhere I can now: markdown, html, reST, etc.
Paul Biggar
One more thing: this makes it much much easier to find text as well. Suppose I wanted to find errors where I had written "straight forward" instead of "straightforward". "straight forward" might have had a line break before, making it hard to grep for. Now it never will.
Paul Biggar
This also makes immediately obvious how long lines are. If you've ever accidentally written a 5 line, 20 comma sentence, you'll know how important this is to stamp out. I don't know a good sentence length exactly, but I can easily spot suspicious ones.
Paul Biggar
A: 

I just use LyX.

280Z28
A: 

I use Auctex with automatic line breaking switched off, and insert line breaks by hand. I avoid auto-formatting, since I want as few changes to where line breaks occur between edits to the document, which makes diffs less cluttered.

Using a smarter diff, one that doesn't care about tex-irrelevant whitespace, would be better, but that's the tool I use.

I like Will's suggestion of hard wrapping per sentence. I thought about it before, but I am fixed in my habits.

Charles Stewart