Visual Studio中:快捷滚动解决方案资源管理到当前文件

问题描述 投票:69回答:10

我不要求选择自动跟随在Solution Explorer当前文件。这已经回答了this question,我有这个选项关闭,因为我讨厌的行为。

我想有一个快捷键(或宏,或....)跳转到我目前编辑在Solution Explorer中的文件。

visual-studio
10个回答
94
投票

在VS 2013有一个内置的键盘快捷键(Ctrl + \,S)

  1. 按Ctrl +反斜杠
  2. 放开两个键
  3. 按S键

或点击下面的图片中所强调的按钮。

我们还必须customize the keyboard shortcut,如果你不喜欢默认的组合的选择:)


0
投票

对于2017年VS默认配置是:

CTRL + [,S

和快捷方式的完整列表,你可以在这里找到:

http://visualstudioshortcuts.com/2017/


61
投票

在Visual Studio 2015年,2017年和2019可以按Ctrl + [再秒。

这将突出显示在Solution Explorer当前正在编辑的文件。


27
投票

据我所知,VS 2012之前没有这样的选择。

在VS 2012中引入了“同步与Active文档”选项。你可以找到this blog说明和屏幕(在页面中间滚动到“同步与Active文档”)。


6
投票

要找到您当前正在编辑Solution Explorer中的文件:

Ctrl + W + S

我以前用过Shift + Alt + L,但由于某些原因,这不再工作。

其他建议(Ctrl+\,SCtrl+[,S和Ctrl +`+ S)没有为我在VS2015工作。我不使用ReSharper的和不喜欢使用宏时,简单的快捷键都可用。


4
投票

在Visual Studio 2015年,与ReSharper的,我可以按Shift + Alt + L键突出显示当前文件在Solution Explorer正在编辑。


3
投票

对于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


3
投票

在Visual Studio 2010/2012您可以使用此扩展名(link)。它增加了选项,以解决方案资源管理器工具栏和代码上下文菜单上的同步。


0
投票

在我的键盘,我不得不按:

按Ctrl +`+ S

请注意,在中间的标志是刚刚离开的退格的关键。

使用Visual Studio 2015年。


0
投票

如果我收到了你的问题的权利,你可以去工具 - >选项 - >项目和解决方案 - >常规,然后选中“跟踪活动项目在Solution Explorer”选项。

© www.soinside.com 2019 - 2024. All rights reserved.