How to locate a file in Solution Explorer in Visua

2019-01-20 22:14发布

I have a huge solution with multiple projects. Sometime I need to navigate to a file in Solution Explorer. Using the VS 2010 'Navigate To' feature I can open any file by name in Visual Studio 2010 but I want to be able to select the file in Solution Explorer as well?

13条回答
聊天终结者
2楼-- · 2019-01-20 22:14

VS2012 added a new command called SolutionExplorer.SyncWithActiveDocument. The default shortcut for c# is Ctrl+[,S

This command will navigate to the active file in the Solution Explorer.

Also, it seems that you need to have the "Track Active Item in Solution Explorer" option turned off.

查看更多
做自己的国王
3楼-- · 2019-01-20 22:15

In the event you want to only track the current file through a keyboard shortcut - the activity is "View.TrackActivityinSolutionExplorer" (assign keys here -> Tools - Options - Environment - Keyboard)

Credit (James' comment)

This worked for me

查看更多
小情绪 Triste *
4楼-- · 2019-01-20 22:16

Visual Studio 2012 has a new shortcut Ctrl [, S. Yes you have to type Ctrl [ and then release and then immediately type S (or click the little sync icon at the top of Solution Explored). It will synchronize to the item.

Of course you can change the shortcut. I think I'll try Alt+L for locate.

Usually this is more useful than always tracking, which in older versions always was a disaster because it would track 100 items in a row and then be jumping all over the place...

查看更多
女痞
5楼-- · 2019-01-20 22:18

Brian Schmitt has a great Locate File in Solution Explorer – Visual Studio Macro post for this. The macro is extremely simple and quick. Basically it toggles the setting

Tools->Options->Projects and Solutions->Track Active Item in Solution Explorer

so that the current file ends up selected in the Solution Explorer but, because it is not left on, you don't get irritated by Solution Explorer nodes being expanded for all the files you access.

Public Sub LocateFileInSolutionExplorer()
    DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer")
    DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer")
    DTE.ExecuteCommand("View.SolutionExplorer")
End Sub

Bind a Keyboard ShortCut to this custom macro to effectively create what should be a built-in Visual Studio feature.

查看更多
SAY GOODBYE
6楼-- · 2019-01-20 22:18

This is actually built in to visual studio without the need for ReSharper (which I love BTW).

http://blogs.msdn.com/b/zainnab/archive/2010/03/29/track-active-item-in-solution-explorer-vstipproj0011.aspx

查看更多
Viruses.
7楼-- · 2019-01-20 22:24

If you want to select the file in the solution explorer on command and don't want to install anything then I would recommend this macro.

I've tested it, setting the shortcut to Alt+T, and I can confirm that it works with VS 2010.

Thanks to Dan Vanderboom for writing it.

查看更多
登录 后发表回答