Is there something as Re-Indent (in Xcode) or Smart Indent (in Matlab) for TeXShop?
[Tex/LaTex] Re-Indent in TeXShop
indentationsourcecodetexshop
Related Solutions
Currently, there is no way to make TeXShop indent long lines as you want. If you would like this feature to be implemented, you can “vote” for this feature request.
However you might want to consider breaking the long lines into shorter ones and manually indenting as you will. Some of the advantages of doing so are:
You get to indent however you want. For example, for itemizes I tend to write
\item Lorem ipsum ... dapibus ac, ... ornare nisi, ...
which doesn't correspond to any if the common automatic wrapping/indenting schemes implemented in text editors.
The indentation is stored in the file, so that yourself and your coauthors can “see” it regardless of the editor you use.
Tools for diffs, file merges and version control benefit from shorter lines (which in turn benefit you!).
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:
- collects all marked text,
- passes it on to Textwrangler
- where the text is properly aligned and broken
- the result is pasted back in TexShop in place of the marked text.
I apply the macro using an assigned keyboard shortcut. I am no Applescript whizkid, so I guess the macro can be improved.
--Applescript
-- Script to transfer the current TeXShop document to TextWrangler
-- Ido Ben-Zvi
-- Based on Ramon Figueroa-Centeno's macros
tell application "TeXShop"
try
activate
set posPath to path of the front document
--return posPath
tell application "System Events" to keystroke "c" using {command down}
tell application "TextWrangler"
activate
tell application "System Events"
keystroke "a" using command down
keystroke "v" using command down
keystroke "a" using command down
end tell
hard wrap selection of text window 1 limit character width width 80 indentation none with paragraph fill and relative
--copy selection of text window 1
--set modified_text to selection of text window 1
tell application "System Events" to keystroke "c" using {command down}
--close myTeXfile
end tell
-- back at TexShop
activate
--set modified of front document to yes
--paste
tell application "System Events"
keystroke "v" using command down
end tell
on error
beep
end try
end tell
--tell application "TextWrangler"
-- close POSIX file FILEPATH
--end tell
Best Answer
Unfortunately there is no way to do this in TeXShop. It's probably the one major failing of it as an editor. You can select portions of text and indent them but since TeXShop soft-wraps lines, this doesn't always do what you want it to do. The code is open-source, and new additions are always welcome, though.