这个里面的
http://code.google.com/p/chromium/wiki/WindowsVisualStudioMacros最后一项的设置一直不能成功,其他没问题,我把内容复制到下面,请教熟悉宏设置的看一下。
Indent to open-paren on line-wrap
This macro is slightly different than the rest. You'll need to put it in your EnvironmentEvents project rather than Module, since it runs on every keypress.
What it does is indent your cursor up to the level of the open-paren on the previous line when you hit Enter.
Public Sub keypress(ByVal key As String, ByVal sel As TextSelection, ByVal completion As Boolean, ByRef cancel As Boolean) _
Handles TextDocumentKeyPressEvents.BeforeKeyPress
If (Not completion And key = vbCr) Then
Dim textDocument As TextDocument = DTE.ActiveDocument.Object("TextDocument")
Dim startPoint As EditPoint = textDocument.StartPoint.CreateEditPoint()
startPoint.MoveToLineAndOffset(sel.ActivePoint.Line, 1)
Dim text = startPoint.GetText(sel.ActivePoint.LineCharOffset - 1)
Dim pos = findUnclosedParenIndent(text)
If pos <> -1 Then
Dim commentPos = text.IndexOf("//")
If commentPos = -1 Or commentPos > pos Then
sel.Insert(vbLf)
sel.DeleteWhitespace()
sel.PadToColumn(pos + 2)
cancel = True
End If
End If
End If
End Sub
Public Function findUnclosedParenIndent(ByRef text As String) As Integer
findUnclosedParenIndent = -1
Dim parens As Char() = "()".ToCharArray()
Dim lastPos = text.Length
Dim numClosed = 0
While True
Dim pos = text.LastIndexOfAny(parens, lastPos - 1)
If pos = -1 Then
Exit While
End If
If text(pos) = ")" Then
numClosed += 1
Else
If numClosed = 0 Then
findUnclosedParenIndent = pos
Exit While
End If
numClosed -= 1
End If
lastPos = pos
End While
End Function
我是把上面这些在EnvironmentEvents里的编译不过,求解