Javascript 如何在java脚本文件中添加区域,visual studio

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46725569/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 03:35:19  来源:igfitidea点击:

How to add region in java script file, visual studio

javascriptangularjs

提问by Sharad

How to add region to collapse and expand code in java script. If any body knows solution, it will be great. thanks in advance.

如何在java脚本中添加区域以折叠和展开代码。如果有人知道解决方案,那就太好了。提前致谢。

回答by Michele Federici

It depends only on the IDE.

这仅取决于IDE

vscode, for example, added support for code regions in september 2017

例如,vscode在 2017 年 9 月添加了对代码区域的支持

https://code.visualstudio.com/updates/v1_17#_folding-regions

https://code.visualstudio.com/updates/v1_17#_folding-regions

For javascript:

对于javascript

//#region

code

//#endregion

or

或者

//region

and

//endregion

The same syntax could work also in different IDEs.

相同的语法也适用于不同的 IDE。

回答by curiousBoy

This works great on Visual Studio 2017 ( I haven't tried with other versions)

这在 Visual Studio 2017 上效果很好(我还没有尝试过其他版本)

Java Script Regions

Java 脚本区域

enter image description here

在此处输入图片说明

JavaScriptRegions

JavaScript 区域

Screen shot for outlining

概述的屏幕截图

enter image description here

在此处输入图片说明

回答by Eid Sky

for older version(vs2015 and below) select your code block => press CTRL + M+H The Code Will be collapsible

对于旧版本(vs2015 及更低版本)选择您的代码块 => 按 CTRL + M+H 代码将可折叠