Home > Coding Helpers > Coding Helpers – Auto Create Region

Coding Helpers – Auto Create Region

January 26th, 2011

If you prefer your code to be wrapped into region directives (#region … #endregion in CSharp, or #Region … #End Region in Visual Basic), the Auto Create Region feature from CodeRush will help. To create a named region around a method, property or event, press “Ctrl+3” key anywhere inside of an active member. This will execute the “RegionAutoCreateaction, which wraps the active member into region directives. The region name will be the same as member’s name and will wrap all attached elements, such as XML doc comments or attributes as well.

CodeRush - Region Auto Create

The RegionAutoCreate command (action) will be performed when there is no text selection and the editor caret is inside of the specified members (method, property or event). If the region directives around the member already exist, new nested region directives will be added.

Note that if you have the Region Painting CodeRush visualization feature turned on – the region directive will be painted in a different way and you won’t see the directives like on the picture:

CodeRush - Region Auto Create with painting

Just put the editor caret on a line that has a region directive, you’ll see the real directive.

The opposite feature of this action is the Remove Region Directives code provider.

—–
Products: CodeRush Pro
Versions: 10.2 and up
VS IDEs: any
Updated: Jan/26/2011
ID: C058

Similar Posts: