Daniel Fisher (lennybacon.com)

SOA, DATA & THE WEB

Visual Studio Team please add comment CSS selection

Until then this Visual Studio macro helps to comment and uncomment in CSS files.

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics

Public Module StyleSheets

    Public Sub CommentCss()
        Dim ts As TextSelection = DTE.ActiveDocument.Selection
        Dim text As String = ts.Text.Trim(" ")

        Dim fileName = DTE.ActiveDocument.FullName

        If Not fileName.EndsWith(".css") Then
            DTE.ExecuteCommand("Edit.CommentSelection")
            Return
        End If

        If String.IsNullOrEmpty(text) Then
            Return
        End If

        ts.Text = "/*" + text + "*/"
    End Sub

    Public Sub UncommentCss()
        Dim ts As TextSelection = DTE.ActiveDocument.Selection
        Dim text As String = ts.Text.Trim(" ")

        Dim fileName = DTE.ActiveDocument.FullName

        If Not fileName.EndsWith(".css") Then
            Return
        End If

        If Not text.StartsWith("/*") And text.EndsWith("*/") Then
            Return
        End If

        ts.Text = text.Substring(2, text.Length - 4)
    End Sub

End Module

Comments

Write a comment