本文转载自:http://blog.devarchive.net/2008/04/using-region-directive-with-javascript.html

这是一个不错的小创意,可以针对大量的javascript脚本实现#region管理的效果. 创意无限啊,赞一个

1.首先编写以下的宏

Option Strict Off
Option Explicit OffImports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Imports System.CollectionsPublic Module JsMacrosSub OutlineRegions()Dim selection As EnvDTE.TextSelection = DTE.ActiveDocument.SelectionConst REGION_START As String = "//#region"Const REGION_END As String = "//#endregion"selection.SelectAll()Dim text As String = selection.Textselection.StartOfDocument(True)Dim startIndex As IntegerDim endIndex As IntegerDim lastIndex As Integer = 0Dim startRegions As Stack = New Stack()DostartIndex = text.IndexOf(REGION_START, lastIndex)endIndex = text.IndexOf(REGION_END, lastIndex)If startIndex = -1 AndAlso endIndex = -1 ThenExit DoEnd IfIf startIndex <> -1 AndAlso startIndex < endIndex ThenstartRegions.Push(startIndex)lastIndex = startIndex + 1Else' Outline region ...selection.MoveToLineAndOffset(CalcLineNumber(text, CInt(startRegions.Pop())), 1)selection.MoveToLineAndOffset(CalcLineNumber(text, endIndex) + 1, 1, True)lastIndex = endIndex + 1End IfLoopselection.StartOfDocument()End SubPrivate Function CalcLineNumber(ByVal text As String, ByVal index As Integer)Dim lineNumber As Integer = 1Dim i As Integer = 0While i < indexIf text.Chars(i) = vbCr ThenlineNumber += 1i += 1End Ifi += 1End WhileReturn lineNumberEnd FunctionEnd Module
2. 然后指派一个快捷键给它
 
这里的快捷键是无所谓的,但一定要两个键
 

3. 然后假设我们有这样的页面

此时,如果按下CTRL+M+,

的确是挺不错的

本文由作者:陈希章 于 2009/7/2 19:55:50 发布在:http://www.cnblogs.com/chenxizhang/
本文版权归作者所有,可以转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
更多博客文章,以及作者对于博客引用方面的完整声明以及合作方面的政策,请参考以下站点:陈希章的博客中心

Using #region Directive With JavaScript Files in Visual Studio 【转载】相关推荐

  1. 未解决:错误的结果 2 (从“D:\Program Files\Microsoft Visual Studio 8\VC\bin\cl.exe”返回)。...

    今天在编译一个VC2005的应用程序时提示该错误.在网上搜了一下这个文件,原来是一个C/C++优化编译器小工具. 我在生成正好在项目属性里面设置了优化速度功能,发现了问题所在. 于是我打开cmd,直接 ...

  2. 1c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(24) : fatal error C1189: #err

    1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(24) : fatal error C1189: # ...

  3. c:\program files\microsoft visual studio\vc98\mfc\include\afxv_w32.h(14) : fatal error C1189:

    编译时报下面错误的解决方法 c:\program files\microsoft visual studio\vc98\mfc\include\afxv_w32.h(14) : fatal error ...

  4. LINK : fatal error LNK1158: cannot run D:\Program Files\Microsoft Visual Studio\VC98\BIN\cvtres.exe

    rebuild一下,是你的debug目录问题,而不是VC的问题. 如果还不行的话,查看Project/setting/link/output file name下的目录是否是debug/zw.exe, ...

  5. 让Visual Studio 也支持JS代码折叠 [ Visual Studio | #region | #endregion ]

    前言 Visual Studio的代码折叠功能非常好用,#region #endregion 这个词连搜狗的词库里面都出现了(不含'#'号),可见使用频率很高,但是他不支持js的代码折叠 : ( 最近 ...

  6. Visual studio 中调试ASP程序、Javascript 代码 - 刘稻博客

    2019独角兽企业重金招聘Python工程师标准>>> PS: 1.在调试asp时,要先附加进程(附加到:自动:与具体调试网站对应的 dllhost.exe 或 w3wp.exe . ...

  7. 创建自定义的Visual Studio项模板

    关键词: VisualStudio 模板 VSDIR    VIZ  目的:     创建自己的Visual Studio类模板,以创建实现单例模式(Singleton)的类为例. 1.何为模板?  ...

  8. sass webpack_如何在Visual Studio和Webpack中编译Sass文件

    sass webpack Sass is a very popular CSS pre-processor. The intent of this tutorial is to show you ho ...

  9. Visual Studio 编程技巧

    技巧 0 删除文件中的当前行: Home + Shife-End + Delete 技巧 1.1 避免意外复制一个空白行 工具->选项->文本编辑器->所有语言->常规: 没有 ...

  10. Visual Studio 博客圈 转载

    为了给关注Visual Studio的用户提供交流的平台,同时能够及时了解到Visual Studio的最新技术,CSDN特别邀请到Visual Studio的技术专家搭建了"Visual ...

最新文章

  1. MySQL数据库时间类型datetime、bigint、timestamp的查询效率比较
  2. 从理论角度理解L1、L2正则化
  3. timestamp 数据类型在 sql_mode 主从不一致引起的不同步问题解决
  4. 寻找获取Bean 的入口
  5. [ZJOI2013]K大数查询
  6. CCF202012-4 食材运输(100分题解链接)
  7. c语言098十进制输出,C语言题库098.doc
  8. 批量修改所选文件夹中所有文件的名称
  9. 兼容所有浏览器的js判断横竖屏以及监听事件
  10. MySQL Error 1048 奇遇记
  11. 假装写在了开头qwq
  12. 软考高项 : 计算题汇总
  13. 单片机C51继电器控制C语言,51单片机对继电器的控制
  14. 编码,隐匿在计算机软硬件背后的语言读书笔记(9)
  15. 微信小程序下载图片与缓存
  16. Git add回退 commit回退
  17. 计算机经典书籍电子书合集
  18. Hello Playwright:(8)等待页面加载
  19. 数据仓库架构的技术选型
  20. 从获评毕马威中国领先地产科技50强 看贝壳的长期主义

热门文章

  1. Linux音频驱动-AOSC之Platform
  2. 系统设计---分层,分级,分块
  3. mysql自动判断索引机制_Mysql优化之索引实现原理
  4. 数据分析之matplotlib和numpy的应用
  5. JAVA异常处理实战心得
  6. awk字符串匹配与传参
  7. kmeans算法详解与spark实战
  8. python应聘要求_python爬取招聘要求等信息实例
  9. mysql 3.23.49,将旧的3.23.49 MySQL数据库转移到5.0.51 MySQL数据库 – 用ANSI和UTF-8编码...
  10. c语言用指针取出字节,在C语言中一个指针占用多少字节。