我不要求的選項自動跟隨在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