# Visual Studio Code Custom Folding Extension This extension enhances the default code folding abilities of Visual Studio Code editor. Regions of code that you'd like to be folded can be wrapped with `#region` comments. ![Custom Folding](https://raw.githubusercontent.com/maptz/Maptz.VSCode.Extensions.customfolding/master/imgs/CSharp_region_wrap.gif) The precise format of the comment depends on the language. For instance, for C-Style languages, regions are of the form: /* #region Main */ public static void Main(string args[]) { //Your code goes here } /* #endregion */ For HTML style languages, you could define a foldable region with the following tags: ## Commands The extension also installs a command to wrap a `region` comment around the current selection. - regionfolder.wrapWithRegion (Ctrl+M Ctrl+R) ## Configuration The extension provides configuration settings, allowing you to provide custom region tags for your language. To provide a custom folding for your language create a settings in your vscode settings file (either user or workspace) that conforms to the following specification. "maptz.regionfolder": { "[ahk]": { //Language selector "foldEnd": "; #endregion", //Text inserted at the end of the fold "foldEndRegex": ";[\\s]*#endregion", //Regex used to find fold end text. "foldStart": "; #region [NAME]", //Text inserted at the start of the fold. //Use the `[NAME]` placeholder to indicate //where the cursor should be placed after //insertion "foldStartRegex": ";[\\s]*#region[\\s]*(.*)", ////Regex used to find fold start text. "disableFolding": false //Turn off #region folding for this language } } ## Installing You can install the latest version of the extension is available on the Visual Studio Marketplace [here](https://marketplace.visualstudio.com/items?itemName=maptz.regionfolder). Alternatively, open Visual Studio code, press `Ctrl+P` and type: > ext install regionfolder ## Features ### Feature - Default Folding A new feature is the notion of `default folds`. Default folds define regions which will be collapsed whenever the file is opened. In the current preview version, default folds are only collapsed when the `regionfolder.collapseDefault` command is issued from the command palette. You can create a default fold by creating a Regex expression which defines the default fold for the language of your choice in your settings file. The Regex is defined in the `defaultFoldStartRegex` property. In the following example, defined for the Markdown language, default folds are defined as regions in the following form: ``` Some default content here ``` The settings for this default fold are below. You can either put this in your Workspace settings file (`.vscode/settings.json`) or in your user profile settings file: ``` "maptz.regionfolder": { "[markdown]": { "defaultFoldStartRegex": "\\", "foldEndRegex": "\\", "foldStartRegex": "\\