Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When you write TeX source, how do you use your editor's word wrap?

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.

like image 625
jparker Avatar asked May 22 '09 17:05

jparker


People also ask

What is word wrap in text editor?

Word wrap is a text editor or word processor feature that breaks lines between words to adjust them within specified margins. This action is performed on the fly; if the user changes the margin, the line is automatically repositioned to ensure that the text is within margins and is visible.

How do you wrap text or code?

You can toggle word wrap for the VS Code session by pressing a key combination. On Windows or Linux, simply press Alt+Z. On MacOS, you can also press Option ⌥ + Z. Alternatively, one can enable/disable word wrapping by selecting View > Word Wrap from the Menu.

What is hard wrap?

A hard wrap inserts actual line breaks in the text at wrap points, with soft wrapping the actual text is still on the same line but looks like it's divided into several lines.


2 Answers

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.

like image 167
Will Robertson Avatar answered Sep 25 '22 11:09

Will Robertson


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.

like image 22
Svante Avatar answered Sep 25 '22 11:09

Svante