출처 : http://jkun75.tistory.com/249

출처 : http://stackoverflow.com/questions/82971/how-to-automatically-remove-trailing-whitespace-in-visual-studio-2008



비주얼 스튜디오에서 Alt + F11 로 Microsoft Visual Studio Macros 실행 후

"MyMacros >> EnvironmentEvents" 에서 End Module 위에 다음 코드 삽입


    Private Sub DocumentEvents_DocumentSaved(ByVal document As EnvDTE.Document) _

    Handles DocumentEvents.DocumentSaved

        Dim fileName As String

        Dim result As vsFindResult


        Try

            fileName = document.Name.ToLower()


            If fileName.EndsWith(".cs") _

            Or fileName.EndsWith(".cpp") _

            Or fileName.EndsWith(".c") _

            Or fileName.EndsWith(".h") _

            Or fileName.EndsWith(".xaml") _

            Or fileName.EndsWith(".ini") _

            Or fileName.EndsWith(".txt") Then

                ' Remove trailing whitespace

                result = DTE.Find.FindReplace( _

                    vsFindAction.vsFindActionFind, _

                    "{:b}+$", _

                    vsFindOptions.vsFindOptionsRegularExpression, _

                    String.Empty, _

                    vsFindTarget.vsFindTargetFiles, _

                    document.FullName, _

                    "", _

                    vsFindResultsLocation.vsFindResultsNone)


                If result = vsFindResult.vsFindResultFound Then

                    result = DTE.Find.FindReplace( _

                        vsFindAction.vsFindActionReplaceAll, _

                        "{:b}+$", _

                        vsFindOptions.vsFindOptionsRegularExpression, _

                        String.Empty, _

                        vsFindTarget.vsFindTargetFiles, _

                        document.FullName, _

                        "", _

                        vsFindResultsLocation.vsFindResultsNone)


                    If result = vsFindResult.vsFindResultReplaced Then

                        ' Triggers DocumentEvents_DocumentSaved event again

                        document.Save()

                    End If

                End If

            End If

        Catch ex As Exception

            MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Trim White Space exception")

        End Try

    End Sub


파일 저장시 마다 해당 파일의 줄 끝 공백을 없애준다.



'C++' 카테고리의 다른 글

현재 프로세스 의 바이너리 풀패스 가져오기  (0) 2013.10.25
네트워크 worker/logic thread에 관한 글  (0) 2013.10.11
GetLastError() : FormatMessage + HTTP  (0) 2013.10.08
Network 제한, 테스트 툴  (0) 2013.10.08
실시간 평균, 분산 계산하기  (0) 2013.08.01
SNMP  (0) 2013.07.19
windows 2008 R2 포트포워딩 netwsh  (0) 2013.07.18
SNMP  (0) 2013.07.12