Using #region directive with javascript files in visual studio


















And: When you compile this program, the region directives do not affect the intermediate language output. Tip: To collapse a region, click the plus-minus sign on the left margin of Visual Studio next to your code.

C Region and endregion Use the region and endregion directives to help organize code blocks. The region directive partitions your code. With region, we can organize code into blocks that can be expanded or collapsed visually. Syntax notes. Veeery handy! Labels: Javascript. Luccy Willdon 30 September at Newer Post Older Post Home.

Even worse, it was hard for other developers to understand everything that my classes were doing. It turns out that I had missed a major code smell in my region frenzy. Instead of wrapping code in region tags, I should have used region boundaries as guidelines to break related code into new classes.

I had the right idea but I was encapsulating too weakly. I let Visual Studio hide complexity and lull me into violating the Single Responsibility principle. 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.

You can install the latest version of the extension is available on the Visual Studio Marketplace here. 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. 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:. The settings for this default fold are below.



0コメント

  • 1000 / 1000