VS2010 扩展了 CSS 区域吗?

VS2010 扩展了 CSS 区域吗?

有人知道 VS2010 中 CSS 区域的扩展吗?我有一些相当大的 CSS 文件,但似乎找不到如何为这些文件创建区域。我有一个 JavaScript 区域扩展,但没有 CSS 区域扩展?

答案1

您可以尝试 JavaScript 折叠宏并//#region更改/*#region*/

查看http://blog.devarchive.net/2008/04/using-region-directive-with-javascript.html

当然,您应该创建一个新的宏并复制/粘贴相同的脚本。

Option Strict Off
Option Explicit Off

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Imports System.Collections

Public Module JsMacros

Sub OutlineCssRegion()
    Dim selection As EnvDTE.TextSelection = DTE.ActiveDocument.Selection

    'Const REGION_START As String = "//#region"
    'Const REGION_END As String = "//#endregion"
    Const REGION_START As String = "/*#region*/"
    Const REGION_END As String = "/*#endregion*/"

    selection.SelectAll()
    Dim text As String = selection.Text
    selection.StartOfDocument(True)

    Dim startIndex As Integer
    Dim endIndex As Integer
    Dim lastIndex As Integer = 0
    Dim startRegions As Stack = New Stack()

    Do
        startIndex = text.IndexOf(REGION_START, lastIndex)
        endIndex = text.IndexOf(REGION_END, lastIndex)

        If startIndex = -1 AndAlso endIndex = -1 Then
            Exit Do
        End If

        If startIndex <> -1 AndAlso startIndex < endIndex Then
            startRegions.Push(startIndex)
            lastIndex = startIndex + 1
        Else
            ' Outline region ...
            selection.MoveToLineAndOffset(CalcLineNumber(text, CInt(startRegions.Pop())), 1)
            selection.MoveToLineAndOffset(CalcLineNumber(text, endIndex) + 1, 1, True)
            selection.OutlineSection()

            lastIndex = endIndex + 1
        End If
    Loop

    selection.StartOfDocument()
End Sub

Private Function CalcLineNumber(ByVal text As String, ByVal index As Integer)
    Dim lineNumber As Integer = 1
    Dim i As Integer = 0

    While i < index
        If text.Chars(i) = vbCr Then
            lineNumber += 1
            i += 1
        End If

        i += 1
    End While

    Return lineNumber
End Function

End Module

答案2

这是一篇旧帖子,但我想我会跟进,因为它仍然出现在 Google(VS CSS 区域)的顶部结果中。

http://jse.codeplex.com/- 此扩展允许类和区域与 VS 2010 中的 CSS 文件折叠。

例子:

/* #region Generic class collection */

.GenericClass {
    border: 1px solid #000000;
    }

.GenericClass2 {
    border: 2px solid #000000;
    }

/* #endregion */

答案3

此功能具有终于成功了到 Visual Studio 2012。:)

用法如@Bjorn Aadnesgaard 描述的。

相关内容