Visual Assist X를 사용하면 제일 편한 기능중 하나가 .h와 .cpp간의 전환 단축키 입니다.

이걸 매크로로 구현한 글이 있어서 링크 합니다.

Visual Studio 2005, 2008에서 동작 확인했습니다.

Function OpenDocument(ByVal path As String) As Window
    If (My.Computer.FileSystem.FileExists(path)) Then
        OpenDocument = DTE.ItemOperations.OpenFile(path)
    Else
        Dim filename As String
        filename = path.Substring(path.LastIndexOf("\") + 1)
        Dim item As ProjectItem
        item = DTE.Solution.FindProjectItem(filename)
        If (item IsNot Nothing) Then
            If (item.Document Is Nothing) Then
                OpenDocument = item.Open()
            Else
                OpenDocument = item.Document.ActiveWindow()
            End If
        End If
    End If
    If (OpenDocument IsNot Nothing) Then
        OpenDocument.Activate()
    End If
End 

Function Sub ToggleBetweenSourceAndHeader()
    Dim document As Document
    document = DTE.ActiveDocument
    Dim path As String
    path = document.FullName
    Dim ext_position As Integer
    ext_position = path.LastIndexOf(".")
    If (ext_position <> -1) Then
        Dim ext As String
        ext = path.Substring(ext_position)
        Dim path_without_ext As String
        path_without_ext = path.Remove(ext_position, ext.Length())
        If (ext.ToLower().Contains(".cpp")) Then     ' .cpp -> .hpp or .h
            If (OpenDocument(path_without_ext & ".hpp") Is Nothing) Then
                OpenDocument(path_without_ext & ".h")
            End If
        ElseIf (ext.ToLower().Contains(".cxx")) Then ' .cxx -> .hxx
            OpenDocument(path_without_ext & ".hxx")
        ElseIf (ext.ToLower().Contains(".cc")) Then  ' .cc -> .hh
            OpenDocument(path_without_ext & ".hh")
        ElseIf (ext.ToLower().Contains(".c")) Then
            OpenDocument(path_without_ext & ".h")
        ElseIf (ext.ToLower().Contains(".h")) Then   ' .h -> .c or .cpp
            If (OpenDocument(path_without_ext & ".c") Is Nothing) Then
                OpenDocument(path_without_ext & ".cpp")
            End If
        ElseIf (ext.ToLower().Contains(".hpp")) Then ' .hpp -> .cpp
            OpenDocument(path_without_ext & ".cpp")
        ElseIf (ext.ToLower().Contains(".hxx")) Then ' .hxx -> .cxx
            OpenDocument(path_without_ext & ".cxx")
        ElseIf (ext.ToLower().Contains(".hh")) Then  ' .hh -> .cc
            OpenDocument(path_without_ext & ".cc")
        End If
    End If
End Sub






posted by 뚱2