SublimeText/LaTeXTools — pull request #430 by btstream (2014-09-11 13:49:02+00:00)
Title: Add features of "fill all", "LaTeX-cwl auto-completion" and "code folding"

Add three features, which is "fill all", "LaTeX-cwl auto-completion" and "better code folding"

# Fill all

This feature does the same thing to the command "fill all" in package of LaTeXing, the default shortcut of which in LaTeXing is "Super+l, Super+l".

NOTE: The default shortcut here is set to "Super+l, Super+f", because "Super+l, Super+l" has already been used in LaTeXTools.

# LaTeX-cwl auto-completion

This is another feature comes from LaTeXing, it use dict files from LaTeX-cwl packages to do auto-completion.

This feature maybe useful for CLS developers.

In order to use this feature, LaTeX-cwl package should be installed.

By default, this feature is turned off in config files. Detailed description of this feature is in "LaTeXTools.default-settings" files.

# Better code folding

By default, sublime text use "%(fold)" and "%...(end)" marks and "tabs" to identify code folding sections in latex source files.

This feature supplies a better code folding behavior. It can recognize "%(fold)" and "%...(end)" mark pairs, if you forget to use this mark, it all OK too. If the marks of "%(fold)" and "%...(end)" are not used, it will auto pair the code folding sections to the next same level's "section start mark" or "parents' start marks". For example, for the code bellow:

```latex
\section{hello} % (fold)
hello world, hello world.
hello world, hello world.
hello world, hello world.
hello world, hello world.

% section hello (end)

\section{hello too} %(fold)
hello world, too
hello world, too
hello world, too
hello world, too
hello world, too

\section{hello again?}
hello again? I am tired.
```
wil be folded to
```latex
\section{hello} % (fold)...
% section hello (end)

\section{hello too} %(fold)...
\section{hello again?}...
```

## shortcut for code folding

Better code folding can ONLY be used by *shortcuts*!
By default, all of the shortcut bellow can be used.

"Alt+Super+[", "Super+k, Super+1", "Super+k, Super+2", "Super+k, Super+3",
... "Super+k, Super+7" are now can be used in latex source file even there are no "tab" used in source files.

And there are three *special* shortcuts, which are:
"Super+k, Super+o": unfold current foding. I don't know why set this command to the shortcut of "Alt+Super+]" does not work for me, so I set it to "Super+k, Super+o" as alternative.

"Super+k, Super+9": fold whole buffer to "Table of Content", which is called "fold to toc".

"Super+k, Super+0": fold whole buffer to TOC but keep the current editing section unfold.

## About fold_to_toc command

Example of fold to toc(Super+k, Super+9) is like this:

If source cod is :

```latex

\chapter{chapter1}

Content before section of hello.

\section{hello} % (fold)
hello world, hello world.
hello world, hello world.
hello world, hello world.
hello world, hello world.

% section hello (end)

\section{hello too} %(fold)
hello world, too
hello world, too
hello world, too

\subsection{hell subsection}

hello world, too
hello world, too

\section{hello again?}
hello again? I am tired.
```
will be fold to
```latex
\chapter{chapter1}...
\section{hello} % (fold)...
\section{hello too} %(fold)...
\subsection{hell subsection}...
\section{hello again?}...
```
if "Super+k, Super+0" is triggered, it will be folded to

```latex
\chapter{chapter1}...
\section{hello} % (fold)...
\section{hello too} %(fold)...
\subsection{hell subsection}

hello world, too
hello world, too

\section{hello again?}...
```

it can be seen that the in the fold to toc command, fold marks of "%(fold)" and "%...(end)" are ignored.

## About extreme fold

These is another fold mode called extreme fold. When extreme fold is used, all fold marks of "%(fold)" and "%...(end)" will be ignored. extreme fold is used only in "fold to toc" by default, but it can be set to other scopes by change the "extreme_fold" option in "laTeXTools.sublime-settings". Detailed description can be found in "laTeXTools.sublime-settings" file.