我不要求的选项自动跟随在Solution Explorer中的当前文件。这已在this question中得到解答,我已关闭此选项,因为我讨厌这种行为。的Visual Studio:快捷滚动解决方案资源管理到当前文件
我想有一个快捷方式(或宏,或....)跳转到我目前在解决方案资源管理器中编辑的文件。
我不要求的选项自动跟随在Solution Explorer中的当前文件。这已在this question中得到解答,我已关闭此选项,因为我讨厌这种行为。的Visual Studio:快捷滚动解决方案资源管理到当前文件
我想有一个快捷方式(或宏,或....)跳转到我目前在解决方案资源管理器中编辑的文件。
据我所知,2012年VS
之前没有这样的选择在VS 2012中引入了“同步与Active文档”选项。您可以在this blog上找到说明和屏幕(滚动到页面中间的“与活动文档同步”)。
对于VS2010,我发现这个宏和我的作品:
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Public Module Utilities
Public Sub TrackProjectItem()
Dim solution As Solution2 = DTE.Solution
If Not solution.IsOpen OrElse DTE.ActiveDocument Is Nothing Then Return
solution.FindProjectItem(DTE.ActiveDocument.FullName).ExpandView()
Dim FileName As String = DTE.ActiveDocument.FullName
Dim SolutionExplorerPath As String
Dim items As EnvDTE.UIHierarchyItems = DTE.ToolWindows.SolutionExplorer.UIHierarchyItems
Dim item As Object = FindItem(items, FileName, SolutionExplorerPath)
If item Is Nothing Then
MsgBox("Couldn't find the item in Solution Explorer.")
Return
End If
DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()
DTE.ActiveWindow.Object.GetItem(SolutionExplorerPath).Select(vsUISelectionType.vsUISelectionTypeSelect)
End Sub
Public Function FindItem(ByVal Children As UIHierarchyItems, ByVal FileName As String, ByRef SolutionExplorerPath As String) As Object
For Each CurrentItem As UIHierarchyItem In Children
Dim TypeName As String = Microsoft.VisualBasic.Information.TypeName(CurrentItem.Object)
If TypeName = "ProjectItem" Then
Dim projectitem As EnvDTE.ProjectItem = CType(CurrentItem.Object, EnvDTE.ProjectItem)
Dim i As Integer = 1
While i <= projectitem.FileCount
If projectitem.FileNames(i) = FileName Then
SolutionExplorerPath = CurrentItem.Name
Return CurrentItem
End If
i = i + 1
End While
End If
Dim ChildItem As UIHierarchyItem = FindItem(CurrentItem.UIHierarchyItems, FileName, SolutionExplorerPath)
If Not ChildItem Is Nothing Then
SolutionExplorerPath = CurrentItem.Name + "\" + SolutionExplorerPath
Return ChildItem
End If
Next
End Function
End Module
原文出处here
在Visual Studio 2010/2012您可以使用此扩展名(link)。 它增加了在Solution Explorer工具栏和代码上下文菜单中同步的选项。
“链接”打开同一页XD – Mate 2013-02-19 18:17:36
抱歉,现在修复。 – user503386 2013-02-20 09:07:40
当您右键单击我们的文档选项卡时,它会在上下文菜单中显示一个新的菜单项“在解决方案资源管理器中查找”。此菜单位于“复制完整路径”和“打开包含文件夹”菜单项之间。 – 2014-04-09 05:26:35
在VS 2013还有一个内置键盘快捷键(CTRL + \,S)
或者单击下图中突出显示的按钮。
人们也有权选择customize the keyboard shortcut如果你不喜欢默认的组合:)
此键盘快捷方式被称为'SolutionExplorer.SyncWithActiveDocument'(工具 - >选项 - >环境 - >键盘) – Laoujin 2015-01-05 11:55:26
默认的快捷键是Ctrl + [,在我的VS. – 2015-04-09 01:23:40
CTRL +反斜杠并没有为我工作的实际,请参阅:http://stackoverflow.com/a/37158527/2874896 – 2016-05-11 09:34:26
在Visual Studio 2015年和2017年,你可以按下Ctrl键+[然后s。
这将突出显示解决方案资源管理器中当前正在编辑的文件。
在Visual Studio 2015中,使用ReSharper,我可以按下“Shift”+“Alt”+“L”以突出显示解决方案资源管理器中正在编辑的当前文件。 – 2016-03-23 14:13:40
在Visual Studio 2013更新5中,这也是正确的组合。 – FrankyHollywood 2016-08-31 05:29:30
@JeremyPaskali非常感谢你。因为我使用resharper多数民众赞成更容易的方式,我去:)。 – C4u 2016-09-14 14:30:19
在我的键盘,我不得不按:
按Ctrl +`+小号
请注意,中间的标志是刚刚离开的退格的关键。
使用Visual Studio 2015。
要找到您目前编辑在Solution Explorer中的文件:
Ctrl + W + S
我以前用过Shift + Alt + L
,但由于某些原因,这不再工作。
其他建议(Ctrl+\,S
和Ctrl+[,S
和Ctrl +`+ S)没有为我在VS2015工作。我不使用resharper,并且在简单快捷键可用时不喜欢使用宏。
在Visual Studio 2015年,与ReSharper的,我能够按移 + Alt键+大号到突出当前文件在Solution Explorer正在编辑。
我也在使用ReSharper,这是我工作的唯一键盘组合。也许ReSharper覆盖VS的默认值? – 2017-01-31 08:44:09
这应该被标记为正确答案,因为它正好回答了问题。 – 2013-06-15 22:25:38
我们现在使用Resharper。它有一个功能来做到这一点。默认快捷键:Shift + Alt + L – Laoujin 2014-02-05 13:18:25
感谢您使用Resharper命令,我也在寻找它。 – bastijn 2014-02-24 10:18:59