Before
//////////////////////////////////////////////////////////////////////////////////////////
/// \brief 글자가
/// 처음으로
/// 나타나는 위치를
/// 반환한다.
/// \param caseSensitive 대소문자 구별을 하는가?
/// \return size_t 음 이것은 그냥 붙여보는 주석이란다. abcdefg hijklmn opqrstu vwxyz 음 이것은 그냥 붙여보는 주석이란다. abcdefg hijklmn opqrstu vwxyz
//////////////////////////////////////////////////////////////////////////////////////////
음 "그냥 붙여보는 주석이란다..." 부분이 원래 한 줄인데, 워드랩되어버리는구나. 어쨌든 원래는 매우 긴 라인이다.
After
//////////////////////////////////////////////////////////////////////////////////////////
/// \brief 글자가 처음으로 나타나는 위치를 반환한다.
/// \param text 검색 대상 문자열
/// \return size_t 음 이것은 그냥 붙여보는 주석이란다. abcdefg hijklmn opqrstu vwxyz 음
/// 이것은 그냥 붙여보는 주석이란다. abcdefg hijklmn opqrstu vwxyz
//////////////////////////////////////////////////////////////////////////////////////////
' 문자열 좌우의 공백을 제거한다.
If Len(strLine) > 0 Then
nBegin = 1
nEnd = Len(strLine)
For i = 1 To Len(strLine)
c = Mid(strLine, i, 1)
If c <> " " And c <> Tab And c <> Lf And c <> Cr Then
nBegin = i
Exit For
End If
Next
For i = 1 To Len(strLine)
c = Mid(strLine, Len(strLine) - i + 1, 1)
If c <> " " And c <> Tab And c <> Lf And c <> Cr Then
nEnd = Len(strLine) - i + 1
Exit For
End If
Next
Return Mid(strLine, nBegin, nEnd - nBegin + 1)
Else
Return ""
End If
End Function
Function GetAsciiLength(ByVal str As String)
Return Encoding.Default.GetBytes(str).Length
End Function
Sub WrapDoxygenComment()
Dim nMaxLength As Integer = 90 - 1 ' -1은 딱 붙어있는 거 찝찝해서
Dim nLineLength As Integer = 0
Dim objRegex As RegularExpressions.Regex
Dim objMatch As RegularExpressions.Match
Dim objStream As New StringBuilder
Dim objLines As New Collection
Dim objSel As TextSelection = ActiveDocument().Selection
Dim objRanges As TextRanges = objSel.TextRanges
Dim objStartPt As EditPoint = objRanges.Item(1).StartPoint.CreateEditPoint()
For Each strLine In objSel.Text.Split(CrLf)
strLine = Strip(strLine)
If objRegex.IsMatch(strLine, "^////+$") Then
Else
objMatch = objRegex.Match(strLine, "^///")
If objMatch.Success Then
strLine = Strip(strLine.SubString(objMatch.Length))
End If
End If
objLines.Add(strLine)
Next
For i = 1 To objLines.Count
strLine = objLines.Item(i)
If strLine.Length = 0 Then
objStream.Append(CrLf)
objStream.Append("/// ")
nLineLength = 0
ElseIf objRegex.IsMatch(strLine, "^////+$") Then
objStream.Append(CrLf)
objStream.Append(strLine)
nLineLength = 0
Else
For Each match As RegularExpressions.Match In RegularExpressions.Regex.Matches(strLine, "\S+\s*")
If nLineLength = 0 Or match.Value.StartsWith("\") Or nLineLength + GetAsciiLength(match.Value) > nMaxLength Then
objStream.Append(CrLf)
objStream.Append("/// ")
nLineLength = 4
End If
objStream.Append(Strip(match.Value) + " ")
nLineLength += GetAsciiLength(Strip(match.Value)) + 1
Next
End If
Next
objStream.Append(CrLf)
' 현재 선택된 문자열을 주어진 문자열로 치환한다.
objSel.Text = ""
objStartPt.Insert(objStream.ToString().Substring(2))
End Sub
정렬하고자 하는 주석을 선택한 다음에 실행할 것. 지속적인 업데이트는 아래의 주소에서...
http://serious-code.net/moin.cgi/VisualStudioMacro#head-0d4b04cbb9f3b4171409fd28d95661d243c6c74b

글
댓글을 달아 주세요
댓글 RSS 주소 : http://serious-code.net/tc/rss/comment/12댓글 ATOM 주소 : http://serious-code.net/tc/atom/comment/12