# How do you get TeXShop to automatically insert line breaks?

As I am using version control (hg) it is convenient to have hard line breaks in my tex files.

Is there a way to set up TeXShop so that it automatically inserts line breaks? (For instance, as I am typing, at some fixed maximum width.)

If this is not possible, is there a convenient command line way to insert hard line breaks into a whole file automatically? (I tried, for instance, "cat longlines.tex | tr '\r' '\n' > shortlines.tex", but this does not work because TeXShop does not even put in Mac breaks '\r'.)

-
When using version control, I find that I want to go the other way: that is, take out the line breaks inserted by the editor. I know nothing about TeXShop, but to remove line breaks (and only have them at sensible places) you could use my script referenced here: tex.stackexchange.com/questions/100/… (there's also a link to a post I wrote about using VCS with LaTeX). If you really want to insert hard line breaks in a whole file according to some fixed line width (but respecting word breaks), use the `fmt` program on unix. – Loop Space May 9 '11 at 19:42
@Chris You can also use Emacs which comes with pretty handy editing features for TeX, and a general line breaking system. – chl May 9 '11 at 20:02
@Andrew, thanks I do also sometimes want to remove line breaks, so that's good to know about. @chl, yes, I vaguely remembered that from my emacs days, but I wanted to avoid having to use two editors for the procedure (ie texshop and emacs), so I'll keep that as a last resort. – Chris May 10 '11 at 23:04
@Chris: Did you notice my comment about the `fmt` program? That inserts the line breaks for you (but I don't know how safe it is with regard to TeX - it might break some stuff in the preamble by inserting line breaks when there shouldn't be any). – Loop Space May 11 '11 at 8:38
@Andrew, Yes, thanks. I looked at the documentation for fmt quickly last night. I was also a touch concerned that it cleaned things up by removing line breaks as well to make paragraphs nice and neat, which of course would be really bad, but perhaps that isn't part of its mandate. – Chris May 11 '11 at 9:14