As pointed out in this question, in TeXShop there is no way to make source paragraphs (i.e. long lines with no hard wraps) follow source indents automatically, that is, while typing. The solution proposed in the accepted answer is unsatisfactory, in my opinion, as it requires manual insertion of line breaks at every single line… I believe you should not be forced to adopt such a behavior in year 2011, unless you are a big fan of old typewriters.
My ultimate goal is to obtain
readable, "programming language-style"
source code, with indented blocks for
environments,
and I would like to get that using TeXShop (I know that's easy using other editors, such as Emacs).
My question is:
is there at least a way to obtain
such a formatting after typing,
e.g. using
a macro which inserts line breaks
in the right spots?
The first thing I tried is the following:
- Write the code naturally, with no indents nor hard wraps;
- Select any block (or even the whole code) and then apply Source > Wrap Lines > Hard Wrap from TeXShop's menu;
- Select any block you want to indent, and indent it using the appropriate command in the Source menu.
However this does not work nicely, because after you indent the block some lines may become too long for the editor window's width.
Best Answer
I not sure what exactly is your required feature, but maybe the following will satisfy you. I make use of another program to do the work, namely Textwrangler, to properly align and insert hard line breaks.
Here is a macro that does the following:
I apply the macro using an assigned keyboard shortcut. I am no Applescript whizkid, so I guess the macro can be improved.