sharelatex/web-sharelatex — pull request #97 by manoyes (2014-08-12 16:06:05+00:00)
Title: Auto indent

This is the first half of a feature I requested in [Issue #152](https://github.com/sharelatex/sharelatex/issues/152). I mentioned using `latexindent.pl` to "beautify" LaTeX. I am still working on that feature; I could probably make a JS function for ACE ([like this](http://jsfiddle.net/HD4uj/)) rather than execute `latexindent.pl` so the code runs clientside per @henryoswald's request.

This pull request implements auto-indenting while typing using ACE's auto indent and outdent feature. It auto-indents after instances of `\begin{...}` as well as when `{`,`(`, or `[` are split across multiple lines, and out-outdents before instances of `\end{...}` and with single `}` on a line. Auto indentation produces the following results, without using TAB or backspace for corrections:

```
\begin{filecontents}{mybib.bib}
@online{
strawberryperl,
title="Strawberry Perl",
url="..."
}
@online{
cmhblog,
title="A Perl script for...",
url="..."
}
\end{filecontents}
```
```
\tikzset{
shrink inner sep/.code={
\pgfkeysgetvalue...
\pgfkeysgetvalue...
}
}
```
```
\def\Picture#1{
\def\stripH{#1}
\begin{pspicture}[showgrid...]
\psforeach{\row}{
{{3,2,1}},
{1,2,3},
...
}{
\expandafter...
}
\end{pspicture}
}
```

I also updated the autocomplete snippets so they are all indented properly when spawned.

This pull request edits a part of the ACE backend. I can submit a pull request to ACE too, if it's appropriate.