<type>documentation</type>
<domain>edit</domain>
<id>folding</id>
<title>Folding</title>
<date>$Date$</date>
<version>$Revision$</version>
<product>per+</product>

Wing's editor supports structural folding for Python, C, C++, Java, Javascript, HTML, JSON, 
Eiffel, Lisp, Ruby, and a number of other file types. This allows you to visually collapse
logical hierarchical sections of code while you are working in other parts of the file.

Editor Fold Margin
------------------

When folding is enabled, a fold margin appears to the left of editors that contain
a file type that can be folded. Left-clicking on marks in this margin 
collapses or expands that fold point.

You can also hold down the following key modifiers while left-clicking, to
modify the folding behavior:

**Shift** while clicking on a fold point expands that point and all its children 
recursively, so that the maximum level of expansion is increased by one.

**Ctrl** while clicking on a fold point collapses that point and all its children 
recursively so that the maximum level of expansion is decreased by one.

**Ctrl-Shift** while clicking on an expanded fold point collapses all child fold 
points recursively.  When the clicked fold point is later re-expanded, its 
children will appear collapsed.  Ctrl-Shift-click on a collapsed fold point 
forces re-expansion of all children recursively to maximum depth.

Folding Menus
-------------

Right-clicking anywhere on the fold margin displays a context menu with folding operations:

**Toggle Fold** collapses or expands the fold point.

**Collapse More** collapses the current fold point one more level.

**Expand More** expands the current fold point one more level.

**Collapse Completely** collapses all children recursively.

**Expand Completely** expands all children recursively to maximum depth.

**Collapse All** collapses the entire file recursively.

**Expand All** expands the entire file recursively.

**Fold Python Methods** collapses all methods in all classes in the file.

**Fold Python Classes** collapses all classes in the file.

**Fold Python Classes and Defs** collapses all classes and top-level
function definitions in the file.
  
These are also available in the ``Folding`` section of the ``Source`` menu, where each
menu item indicates the key equivalents assigned to the operation in your current
`Keyboard Personality <ref:custom/keyboard-personalities>`__.  Items in this menu
operate on the first fold point found in the current editor selection or on
the current line.

Folding Preferences
-------------------

You can turn folding on and off and adjust the style and color of fold marks with the
`Editor > Folding <script:show_preferences_gui#prefname="edit.enable-folding">`__ preferences.

