Turbocharge your Python development with the latest release of PyScripter!

Code foldingEditorPyScripterPython

Code folding in PyScripter

A much requested new feature in PyScripter 3.1 is support for code folding.  Before I explain how to use it let me make it clear that if you believe that code folding is an unwanted gimmick you can disable it through the Tools, Options, IDE Options menu selection.  Just uncheck “Code folding enabled by default” under Editor options.


You can fold sections of the code by clicking the + (plus) signs in the gutter and can unfold folded sections by clicking the – (minus) signs or by clicking at the boxes with the three dots at the end of the lines (see picture above).

Code folding commands

The code folding commands can be fount in the context menu of the editor (i.e. you can see them by right-clicking on the editor).   There are editor shortcuts defined for many of these functions.  The default editor shortcuts are listed below.

Command Shortcut Description
Fold All Shft+Ctrl+- Fold all ranges
Unfold All Shft+Ctrl+/ Unfold all ranges
Fold Nearest Ctrl+/ Fold nearest range
Unfold Nearest Shft+Ctrl+/ Unfold nearest range
Fold Regions   Fold all regions
Unfold Regions   Unfold all regions
Fold Level 1 Ctrl+K Ctrl+1 Fold top level ranges (level 1)
Unfold Level 1 Shft+Ctrl+K Shft+Ctrl+1 Unfold top level ranges (level 1)
Fold Level 2 Ctrl+K Ctrl+2 Fold level 2 ranges
Unfold Level 2 Shft+Ctrl+K Shft+Ctrl+2 Unfold level 2 ranges
Fold Level 3 Ctrl+K Ctrl+3 Fold level 3 ranges
Unfold Level 3 Shft+Ctrl+K Shft+Ctrl+3 Unfold level 3 ranges
Fold Functions   Fold all functions (IDE command)
Unfold Functions   Unfold all functions (IDE command)
Fold Classes   Fold all classes (IDE command)
Unfold Classes   Unfold all classes (IDE command)

Note:  Regions are areas of the file that  start with #region and  end with

#endregion. e.g.

#region Description


Leave a Reply