在Visual Studio 2008中是否有一种方法可以将结束大括号转换为开始大括号?我发现了大量关于突出显示大括号的内容,但没有关于将光标移到大括号上的内容。
(VB。这个问题的NET版本:键盘快捷键在“If/End If”之间跳转)
在Visual Studio 2008中是否有一种方法可以将结束大括号转换为开始大括号?我发现了大量关于突出显示大括号的内容,但没有关于将光标移到大括号上的内容。
(VB。这个问题的NET版本:键盘快捷键在“If/End If”之间跳转)
当前回答
在我的pt-BR(巴西葡萄牙语)键盘上,它实际上是CTRL +[。
其他回答
在土耳其键盘上,它是Ctrl + ü。
为了完整起见,在瑞典键盘上,它是CTRL + å。
另外,我认为这是合乎逻辑的,但值得一提的是CTRL + shift + å(对于大写Å),选择括号内的所有内容并转到匹配的内容。
如果出于某种原因,这对你来说不工作,可能是某些东西打乱了你的键盘绑定(这对我来说不工作)。不过,你可以很容易地重新启用绑定-至少我是这么想的:
我尝试了这个方法:
进入菜单工具->选项->环境->键盘 滚动到或搜索“编辑”命令。GotoBrace 指定所需的快捷方式(我的快捷方式是空的,所以我输入CTRL +]) 请务必点击“分配按钮”。
我试过了,还是不行。我重新启动了Visual Studio,它仍然不能工作-好吧,它只工作于。cs文件,但我需要它工作于。vb文件和文本文件,以及…所有文件!
有点相关,但对于HTML标签:(因为没有内置的解决方案,Ctrl + J不适用于HTML标签:)
下面是答案,作为一个宏,我已经建立了它(切换),包括去焦点:
下面是演示:
这是代码。享受吧!
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Imports System.Windows.Forms
Public Module Module2
Sub beginToEnd()
'Place the cursor somewhere in the beginning tag, run the macro, to select from beginning to end tag
DTE.ActiveDocument.Selection.SelectLine()
Dim objSel As TextSelection = DTE.ActiveDocument.Selection
Dim topPoint As TextPoint = objSel.TopPoint
Dim lTopLine As Long = topPoint.Line
objSel.GotoLine(lTopLine, False)
' DTE.ActiveDocument.Selection.StartOfLine()
DTE.ActiveDocument.Selection.SelectLine()
Dim line1 As String = DTE.ActiveDocument.Selection.Text()
If InStr(line1, "/") Then
' MsgBox(line1)
DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText, True)
objSel.GotoLine(lTopLine, False)
DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")
DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")
Else
DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")
DTE.ActiveDocument.Selection.EndOfLine(False)
DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")
End If
DTE.ActiveDocument.Selection.SelectLine()
Dim line2 As String = DTE.ActiveDocument.Selection.Text()
Dim objSel3 As TextSelection = DTE.ActiveDocument.Selection
Dim topPoint3 As TextPoint = objSel3.TopPoint
Dim lTopLine3 As Long = topPoint3.Line
objSel.GotoLine(lTopLine3, False)
DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText, False)
End Sub
End Module
对于Visual Studio Code(见其文档),使用Ctrl+Shift+\。
设置可以在以下地址找到:
文件/参数/键盘快捷键
我使用的是Visual Studio Code 1.8.0。注意:对于国际键盘,Visual Studio Code的行为可能有所不同(参见这个回答re: German keyboard)
希望这能帮助到一些人。