When using the LaTeX bundle, "Reformat paragraph" isn't very clever
about respecting things like environments that aren't separated by a
blank line and commands like \item and \caption that might take
paragraph text. Is it possible to customise this?
I think it's more a question of someone just writing a "reformat
paragraph" script for LaTeX files. Then you can bind it to the same
keystroke. But I don't know of any such "latex beautifier". If we can
formalize precisely what such a script should be doing, it will
probably be not too hard to write one.
The standard LaTeX bundles still(!) ships with an old LaTeX Tidy I wrote, under "Tidy". It is simple-minded and works on the whole document. You should try it out and see if it gets close to what you want. You may be able to effectively customize it (it's a perl script LaTeXTidy.pl in Latex.tmbundle/Support/bin). Here are the notes from the script comments:
# General Idea # ------------
# Eat all single newlines. Add newlines after all "\" # Newlines before each \begin and \end. After each \end{} # Each environment \begin adds a level of tab. # Newlines before each \item. # \n before each [ and after each ]
best wishes, Eric -- Eric Hsu, Associate Professor of Mathematics San Francisco State University http://math.sfsu.edu/hsu erichsu@math.sfsu.edu