vs 的宏设置

nyb 2013-04-23 11:57:07
这个里面的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里的编译不过,求解
...全文
155 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
lin5161678 2013-04-23
  • 打赏
  • 举报
回复
引用 1 楼 zhao4zhong1 的回复:
编译选项加/EP /P,重新编译,查看宏展开后对应的.i文件。gcc加-E
不是C/C++代码 也能这样用????!
逸萌 2013-04-23
  • 打赏
  • 举报
回复
编译选项加/EP /P,重新编译,查看宏展开后对应的.i文件。gcc加-E
up
赵4老师 2013-04-23
  • 打赏
  • 举报
回复
编译选项加/EP /P,重新编译,查看宏展开后对应的.i文件。gcc加-E

64,691

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧