'foldlevel' to all folds that don't contain the cursor.
You have to try it out if you like how this feels. Use |zm| to fold more and
|zr| to fold less (reduce folds).
The folding is local to the window. This allows you to open two windows on
the same buffer, one with folds and one without folds. Or one with all folds
closed and one with all folds open.
==============================================================================
*28.4* Saving and restoring folds
When you abandon a file (starting to edit another one), the state of the folds
is lost. If you come back to the same file later, all manually opened and
closed folds are back to their default. When folds have been created
manually, all folds are gone! To save the folds use the |:mkview| command: >
:mkview
This will store the settings and other things that influence the view on the
file. You can change what is stored with the 'viewoptions' option.
When you come back to the same file later, you can load the view again: >
:loadview
You can store up to ten views on one file. For example, to save the current
setup as the third view and load the second view: >
:mkview 3
:loadview 2
Note that when you insert or delete lines the views might become invalid.
Also check out the 'viewdir' option, which specifies where the views are
stored. You might want to delete old views now and then.
==============================================================================
*28.5* Folding by indent
Defining folds with |zf| is a lot of work. If your text is structured by
giving lower level items a larger indent, you can use the indent folding
method. This will create folds for every sequence of lines with the same
indent. Lines with a larger indent will become nested folds. This works well
with many programming languages.
Try this by setting the 'foldmethod' option: >
:set foldmethod=indent
Then you can use the |zm| and |zr| commands to fold more and reduce folding.
It's easy to see on this example text:
This line is not indented
This line is indented once
This line is indented twice
This line is indented twice
This line is indented once
This line is not indented
This line is indented once
This line is indented once
Note that the relation between the amount of indent and the fold depth depends
on the 'shiftwidth' option. Each 'shiftwidth' worth of indent adds one to the
depth of the fold. This is called a fold level.
When you use the |zr| and |zm| commands you actually increase or decrease the
'foldlevel' option. You could also set it directly: >
:set foldlevel=3
This means that all folds with three times a 'shiftwidth' indent or more will
be closed. The lower the foldlevel, the more folds will be closed. When
'foldlevel' is zero, all folds are closed. |zM| does set 'foldlevel' to zero.
The opposite command |zR| sets 'foldlevel' to the deepest fold level that is
present in the file.
Thus there are two ways to open and close the folds:
(A) By setting the fold level.
This gives a very quick way of "zooming out" to view the structure of the
text, move the cursor, and "zoom in" on the text again.
(B) By using |zo| and |zc| commands to open or close specific folds.
This allows opening only those folds that you want to be open, while other
folds remain closed.
This can be combined: You can first close most folds by using |zm| a few times
and then open a specific fold with |zo|. Or open all folds with |zR| and
then close specific folds with |zc|.
But you cannot manually define folds when 'foldmethod' is "indent", as that
would conflict with the relation between the indent and the fold level.
More about folding by indent in the reference manual: |fold-indent|
==============================================================================
*28.6* Folding with markers
Markers in the text are used to specify the start and end of a fold region.
This gives precise control over which lines are included in a fold. The
disadvantage