visual-studio 如何在 Visual Studio 2010 的解决方案资源管理器中定位文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3436222/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to locate a file in Solution Explorer in Visual Studio 2010?
提问by Amitabh
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 Exploreras well?
我有一个包含多个项目的巨大解决方案。有时我需要导航到解决方案资源管理器中的文件。使用 VS 2010 的“导航到”功能我可以在 Visual Studio 2010 中按名称打开任何文件,但我也希望能够在解决方案资源管理器中选择文件?
回答by Jeff Mercado
There's an option to track the active (open and viewed) item in the solution explorer. If the file is in view, the file in the solution explorer will be selected.
有一个选项可以跟踪解决方案资源管理器中的活动(打开和查看)项目。如果文件在视图中,则将选择解决方案资源管理器中的文件。
Tools->Options->Projects and Solutions->Track Active Item in Solution Explorer
工具->选项->项目和解决方案->在解决方案资源管理器中跟踪活动项
回答by Aaron Carlson
VS2012 added a new command called SolutionExplorer.SyncWithActiveDocument. The default shortcut for c# is Ctrl+[,S
VS2012 添加了一个名为SolutionExplorer.SyncWithActiveDocument. c# 的默认快捷方式是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.
此外,您似乎需要关闭“在解决方案资源管理器中跟踪活动项目”选项。
回答by Rob Willis
Shift+Alt+Lwill find the current file in Solution Explorer in Visual Studio 2008+ with ReSharper installed.
Shift+ Alt+L将在安装了 ReSharper 的 Visual Studio 2008+ 中的解决方案资源管理器中找到当前文件。
回答by HuBeZa
I found the track option to be a little annoying.
我发现轨道选项有点烦人。
I prefer to use DPack. It contain "Locate In Solution Explorer" operation, plus many other features (some are less powerful in VS2010, like their browsers), and it's free.
我更喜欢使用DPack。它包含“在解决方案资源管理器中定位”操作,以及许多其他功能(有些功能在 VS2010 中功能较弱,例如它们的浏览器),并且它是免费的。


Note that ReSharperalso have the locate feature that works batter than DPack's (in some cases, DPack's locate won't work if the file is collapsed behind folders), but you don't want to buy ReSharperonly for this feature.
请注意,ReSharper还具有比 DPack 更有效的定位功能(在某些情况下,如果文件折叠在文件夹后面,DPack 的定位将不起作用),但您不想仅为此功能购买 ReSharper。
回答by Martin Hollingsworth
Brian Schmitthas a great Locate File in Solution Explorer – Visual Studio Macropost for this. The macro is extremely simple and quick. Basically it toggles the setting
布赖恩施密特在解决方案资源管理器中有一个很棒的定位文件——Visual Studio 宏帖子。宏非常简单快捷。基本上它切换设置
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 ShortCutto this custom macro to effectively create what should be a built-in Visual Studio feature.
回答by Shay
If you have ReSharper and want to add "Locate in Solution Explorer" to the tab's context menu:
如果您有 ReSharper 并希望将“在解决方案资源管理器中定位”添加到选项卡的上下文菜单中:
- Go to Tools -> Customize -> Commands -> Context Menu
- Select "Other Context Menus | Easy MDI Document Window".
- Click "Add Command".
- Choose "Resharper" -> "ReSharper_LocateInSolutionOrAssemblyExplorer" (in VS2019, the category name was changed to "Extensions")
- "OK" -> "Close"
- 转到工具 -> 自定义 -> 命令 -> 上下文菜单
- 选择“其他上下文菜单 | Easy MDI 文档窗口”。
- 单击“添加命令”。
- 选择“Resharper”->“ReSharper_LocateInSolutionOrAssemblyExplorer”(在VS2019中,类别名称改为“扩展”)
- “确定”->“关闭”
Now, when right click on any tab and you'll see a new option: Locate in Solution Explorer.
现在,当右键单击任何选项卡时,您将看到一个新选项:在解决方案资源管理器中定位。
UPDATE:
更新:
Following the comment from @jeremy-paskali, you can set a keyboard shortcut for this command:
按照@jeremy-paskali 的评论,您可以为此命令设置键盘快捷键:
- Go to Tools -> Customize -> "Keyboard..."
- Search for "ReSharper.ReSharper_LocateInSolutionOrAssemblyExplorer" in the "Show commands containing" field and select it.
- Review the currently assigned shortcuts in the drop down below.
- Make any changes, if needed.
- "OK" -> "Close"
- 转到工具 -> 自定义 -> “键盘...”
- 在“显示包含的命令”字段中搜索“ReSharper.ReSharper_LocateInSolutionOrAssemblyExplorer”并选择它。
- 在下面的下拉列表中查看当前分配的快捷方式。
- 如果需要,进行任何更改。
- “确定”->“关闭”
回答by friend
I know its little too late, but hope it helps someone else. The best option now is to install Microsoft Visual Studio add on called - Productivity Power Tools.
我知道为时已晚,但希望它对其他人有所帮助。现在最好的选择是安装 Microsoft Visual Studio 插件,名为 - Productivity Power Tools。
http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef
http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef
With this comes "Solution Navigator" (alternative to Solution Explorer, with a lot of benefits) - which then you can use to filter the files to only show "Open". You can even filter files to show "Edited" and "Unsaved".
随之而来的是“解决方案导航器”(替代解决方案资源管理器,具有很多好处) - 然后您可以使用它来过滤文件以仅显示“打开”。您甚至可以过滤文件以显示“已编辑”和“未保存”。
回答by Simon_Weaver
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.
Visual Studio 2012 有一个新的快捷方式Ctrl [, S。是的,您必须键入Ctrl [然后释放,然后立即键入S(或单击“解决方案探索”顶部的小同步图标)。它将同步到项目。
Of course you can change the shortcut. I think I'll try Alt+Lfor locate.
当然,您可以更改快捷方式。我想我会尝试Alt+L定位。
If you want to change the shortcut, it's command name under Options\Environment\Keyboardis SolutionExplorer.SyncWithActiveDocument.
如果要更改快捷方式,它的命令名下Options\Environment\Keyboard的SolutionExplorer.SyncWithActiveDocument。
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...
通常这比总是跟踪更有用,这在旧版本中总是一场灾难,因为它会连续跟踪 100 个项目,然后到处跳跃......
回答by pingo
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)
如果您只想通过键盘快捷键跟踪当前文件 - 活动是“View.TrackActivityinSolutionExplorer”(在此处分配键 -> 工具 - 选项 - 环境 - 键盘)
This worked for me
这对我有用
回答by Vince Panuccio
This is actually built in to visual studio without the need for ReSharper (which I love BTW).
这实际上是内置在视觉工作室中的,不需要 ReSharper(我喜欢 BTW)。

