사용자 도구

사이트 도구


tool:microsoft-visual-studio:매크로

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

다음 판
이전 판
tool:microsoft-visual-studio:매크로 [2013/06/20 13:53] – 새로 만듦 kieunstool:microsoft-visual-studio:매크로 [2024/04/23 22:44] (현재) – 바깥 편집 127.0.0.1
줄 1: 줄 1:
 +====== Macro : Header Source Toggle ======
  
 +  * 출처 : [[http://bytedevil.tistory.com/7|20Visual Studio에서 *.c, *.cpp(소스) 와 *.h, *.hpp(헤더) 전환하기]]
 +
 +  - Alt+F11 로 매크로 편집기 오픈
 +  - 아래 매크로를 추가
 +  - 키보드 설정에서, "매크로." 또는 "Macro." 를 타이핑 해서 내가 작성한 매크로 찾기
 +  - 키 할당
 +  - 사용하기
 +
 +++++ 코드 보기 |
 +<code vbnet>
 +    Public Sub toggleHeaderSource()
 +        Dim currentDocumentPath As String = DTE.ActiveDocument.FullName
 +        currentDocumentPath = currentDocumentPath.ToLower()
 +
 +        Dim currentDocumentPathWithoutExtension As String = currentDocumentPath.Remove(currentDocumentPath.LastIndexOf("."))
 +
 +        Dim correspondingDocumentPath As String
 +        Dim correspondingDocumentPath2 As String
 +
 +        If (currentDocumentPath.EndsWith(".c") Or currentDocumentPath.EndsWith(".cpp")) Then
 +            correspondingDocumentPath = currentDocumentPathWithoutExtension + ".hpp"
 +            correspondingDocumentPath2 = currentDocumentPathWithoutExtension + ".h"
 +        ElseIf (currentDocumentPath.EndsWith(".h") Or currentDocumentPath.EndsWith(".hpp")) Then
 +            correspondingDocumentPath = currentDocumentPathWithoutExtension + ".cpp"
 +            correspondingDocumentPath2 = currentDocumentPathWithoutExtension + ".c"
 +        End If
 +
 +        If (System.IO.File.Exists(correspondingDocumentPath) = True) Then
 +            DTE.ExecuteCommand("File.OpenFile", correspondingDocumentPath)
 +        ElseIf (System.IO.File.Exists(correspondingDocumentPath2) = True) Then
 +            DTE.ExecuteCommand("File.OpenFile", correspondingDocumentPath2)
 +        End If
 +    End Sub
 +
 +</code>
 +++++
 +
 +====== Visual Studio 매크로 ======
 +
 +VS2010에는 플러그인 개발이 오픈소스화 되어 좋은 것들을 쉽게 구할 수 있게 되었다.
 +
 +뭔가 불편하면, 플러그인을 찾으면 된다.
 +
 +이 스크립트는 낡았다. 그냥 추억으로 나둠.
 +
 +++++ Old Script |
 +
 +<code vb>
 +Imports System
 +Imports EnvDTE
 +Imports EnvDTE80
 +Imports EnvDTE90
 +Imports EnvDTE90a
 +Imports EnvDTE100
 +Imports System.Diagnostics
 +
 +Public Module MyMacroModule
 +
 +    Public Sub toggleHeaderSource()
 +        Dim currentDocumentPath As String = DTE.ActiveDocument.FullName
 +        currentDocumentPath = currentDocumentPath.ToLower()
 +
 +        Dim currentDocumentPathWithoutExtension As String = currentDocumentPath.Remove(currentDocumentPath.LastIndexOf("."))
 +
 +        Dim correspondingDocumentPath As String
 +        Dim correspondingDocumentPath2 As String
 +
 +        If (currentDocumentPath.EndsWith(".c") Or currentDocumentPath.EndsWith(".cpp")) Then
 +            correspondingDocumentPath = currentDocumentPathWithoutExtension + ".hpp"
 +            correspondingDocumentPath2 = currentDocumentPathWithoutExtension + ".h"
 +        ElseIf (currentDocumentPath.EndsWith(".h") Or currentDocumentPath.EndsWith(".hpp")) Then
 +            correspondingDocumentPath = currentDocumentPathWithoutExtension + ".cpp"
 +            correspondingDocumentPath2 = currentDocumentPathWithoutExtension + ".c"
 +        End If
 +
 +        If (System.IO.File.Exists(correspondingDocumentPath) = True) Then
 +            DTE.ExecuteCommand("File.OpenFile", correspondingDocumentPath)
 +        ElseIf (System.IO.File.Exists(correspondingDocumentPath2) = True) Then
 +            DTE.ExecuteCommand("File.OpenFile", correspondingDocumentPath2)
 +        End If
 +    End Sub
 +
 +    Sub InsertTMacro()
 +        Dim selection As EnvDTE.TextSelection
 +        Dim startPoint As EnvDTE.EditPoint
 +        Dim endPoint As TextPoint
 +        Dim commentStart As String
 +
 +        selection = DTE.ActiveDocument.Selection()
 +        startPoint = selection.TopPoint.CreateEditPoint()
 +        endPoint = selection.BottomPoint.CreateEditPoint()
 +
 +        DTE.UndoContext.Open("InsertTMacro")
 +        Try
 +            startPoint.Insert("_T(")
 +            endPoint.Insert(")")
 +        Finally
 +            DTE.UndoContext.Close()
 +        End Try
 +    End Sub
 +
 +End Module
 +</code>
 +
 +++++