Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save t-bltg/c93876f7f88d5c3f4090 to your computer and use it in GitHub Desktop.
Save t-bltg/c93876f7f88d5c3f4090 to your computer and use it in GitHub Desktop.
LaTeX indentation rules for Sublime Text. See usage in comments below.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Indentation Rules</string>
<key>scope</key>
<string>text.tex, sources.bib</string>
<key>settings</key>
<dict>
<key>decreaseIndentPattern</key>
<string>(?x)
# \end{...} + some comments
^\s*\\end\{[^\{\}]+\}.*$
# \] + some comments
| ^\s*\\\].*$
# a closing brace } + some comments
| ^\s*\}.*
# \fi
| ^\s*\\fi\s*$
</string>
<key>increaseIndentPattern</key>
<string>(?x)
# \begin{...} + optionnal {...} and/or [...] + optionnals, but only if \end{} not on same line
^\s*\\begin\{[^\{\}]+\}(\{.*\}|\[.*\])*[^\}]*\s*$
# beginning of math mode display \[ + spaces
| ^.*\\\[\s*$
# backslash + a command containing no backslashes + opening bracket or arrobase i.e. \textbf{ or @misc{ + any character
| ^.*(\\|\@)([^\\]+|def.*)\{[^\}]*$
# }{ for ifthenelse struct or a single opening brace { + some characters
| ^\s*(\})*\{.*$
# \if...
| ^\s*\\if(num|dim|odd|vmode|hmode|mmode|inner|cat|x|void|eof|true|case|beamer)\S*\s*$
# else
| ^\s*\\else.*$
</string>
<key>unIndentedLinePattern</key>
<string>(?x)
# \else
^\s*\\else.*$
</string>
</dict>
<key>uuid</key>
<string>02EB44C6-9203-4F4C-BFCB-7E3360B12842</string>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment