8.2 Customizing what to fold

8.2.1 Tex_FoldedSections
8.2.2 Tex_FoldedEnvironments
8.2.3 Tex_FoldedCommands
8.2.4 Tex_FoldedMisc
8.2.5 Advanced Fold setting details

From version 1.6 onwards, the folding in Latex-Suite can be controlled to a large extent via a number of global variables.

8.2.1 Tex_FoldedSections

This entry defines which sections will be folded. This setting is a comma separated list of section names. The default value is:

part,chapter,section,subsection,subsubsection,paragraph

Each of the entries in the list will fold up a section of the corresponding name and the corresponding %%fakesection. The %%fakesection section is provided as a means for the user to group lines into "fake" sections. In particular, it is useful to fold the introduction of a section that is not part of a subsection:

\section{Latex-Suite}
%%fakesubsection Introduction
A short introduction of the features of Latex-Suite.
\subsection{Installation}
Installation instructions.

Without the %%fakesubsection the introduction would not be folded separately from the section.

It is also possible, to add section names at the same level of hierarchy. These have to be separated by "|". This is, e.g., useful for the KOMA classes, which add "\addcap":

" let g:Tex_FoldedSections = 'part|addpart,chapter|addchap,section|addsec,subsection,subsubsection,paragraph,subparagraph'

See also advanced fold settings.

8.2.2 Tex_FoldedEnvironments

This entry defines which environments will be folded. It is a comma separated string of words each of which defines a single environment. The default setting is

verbatim,comment,eq,gather,
align,figure,table,thebibliography,
keywords,abstract,titlepage

The words need not be standard Latex environments. You can add any word you like. Also, each word will fold up all environments whose name begins with that word. For example, in the setting above, the word "eq" folds up the \begin{equation}, \begin{eqnarray}, \begin{eqnarray*} environments. To avoid this, you can replace the word "eq" with "eq}".

See also advanced fold settings.

8.2.3 Tex_FoldedCommands

This entry defines which commands will be folded. It is a comma separated string of words each of which defines a single command. The default setting is empty, i.e no commands are folded. The words need not be standard Latex commands. You can use whatever words you like. Each word will fold all commands whose name begins with that word as in the case of the Tex_FoldedEnvironments variable.

Note

It is very difficult to fold commands reliably because it is very difficult to create a regexp which will match a line containing unmatched parentheses (or curly brackets), but will not match a line containing matched parentheses.

Just to make things safer, only lines which start a command but do not contain additional curly braces after the command has started are folded. In other words, if you wanted to fold the the command "mycommand", then the lines

\mycommand{This is a line
and some more text on the next line
}

will be folded, but the lines

\mycommand{This is a \textbf{line}
and some more text
}

will not be folded. This is a bug which is very difficult to fix.

See also advanced fold settings.

8.2.4 Tex_FoldedMisc

This entry defines fold syntax for certain items which do not naturally fit into the section, environment of command lists. It is a comma separated list of words. The default value is:

item,preamble,<<<

Note

Unlike the other Tex_FoldedXXXX variables, the words in this setting are limited to take values from the following list:

ValueMeaning
commentsFolds up contiguous blocks of comments
itemFolds up the \items within list environments
preambleFolds up the preamble of a document. (The part between the \documentclass command and the \begin{document} environment)
<<<Folds defined manually by the user using the <<< and >>> strings as fold-markers.

Any other words in the Tex_FoldedMisc setting are silently ignored.

See also advanced fold settings.

8.2.5 Advanced Fold setting details

The order of the words in the Tex_FoldedXXXX variables is important. The order defines the order in which the folds are nested. For example, the value "subsection,section" for the Tex_FoldedSections variable will not fold any subsections at all. This is because the folds are created in the reverse order in which they occur in the Tex_FoldedSections setting and also, once a fold is created, the interior of the fold is not examined for creating additional folds. In the above case, this means that a \section is folded first and then its interior is not examined further. The correct value should have been "section,subsection"

Each of the fold setting variables Tex_FoldedSections, Tex_FoldedEnvironments etc., as explained previously is a comma separated string of variables. However, to make it easier to add to the default settings without having to repeat the whole default setting again, Latex-Suite uses the following logic in forming the complete setting string from the Tex_FoldedXXXX variables. If the variable starts with a comma, then Tex_FoldedXXXX is added to the end of the default string rather than replacing it. Similarly, if it ends with a comma, then it will be prepended to the beginning of the default setting rather than replacing it.

For example, if Tex_FoldedEnvironments is set to the string "myenv", then only an environment of the form \begin{myenv} will be folded. However, if the Tex_FoldedEnvironments setting is ",myenv", then the \begin{myenv} environment will be folded after all other environments in the default setting have been folded. On the other hand if Tex_FoldedEnvironments is of the form "myenv,", the \begin{myenv} environment will be folded before the rest of the environments in the default setting.