Collapsing javascript code in visual studio [closed]
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this questionI’m looking for equivalent functionality to C# regions in javascript
C# syntax
#region RegionName
public static void MyFunction()
{
[mycode]
}
#endregion
This allows me to “collapse” my code in my .js file with Visual Studio and make it a little more manageable.
Anybody got any ideas?
If it need for collapse the java script code then you may select the code and press
Ctrl + M + H
It will collapse the selected code.
Microsoft now has an extension for VS2010 that provides this functionality:
JScript Editor Extensions
This feature can be installed in Visual Studio 2012 with the help of Web Essentials plugin.
EDIT:
To do an actual region you can use:
//#region MyRegion
function Example() {
}
//#endregion
The plugin can be downloaded here: Web Essentials 2012, Web Essentials for 2010
Take a look at this article, which implements the #region directives in js files using macros.
For Visual Studio 2012, you can use this extension: http://visualstudiogallery.msdn.microsoft.com/4be701d8-af03-40a4-8cdc-d2add5cde46c
There is a javascript outlining extension for VS 2010 here http://jsoutlining.codeplex.com/documentation it works great for me
This is the best one (I've tried them all):
http://visualstudiogallery.msdn.microsoft.com/0696ad60-1c68-4b2a-9646-4b5f4f8f2e06/view/Discussions/1
精彩评论