我经常使用 Visual Studio 的多个实例,经常处理同一解决方案的不同分支。

VC6 曾经在其标题栏中显示当前源文件的完整路径,但 Visual Studio 2005 似乎没有这样做。这使得弄清楚我当前正在查看的解决方案的哪个分支变得更加尴尬(我知道的最快方法是将鼠标悬停在选项卡上,这样您就可以获得源文件的路径作为工具提示)。

有什么方法可以将完整的解决方案或文件路径放入标题栏,或者至少放在始终可见的地方,以便我可以快速判断哪个分支加载到每个实例中?

有帮助吗?

解决方案

没有本地方法可以做到这一点,但您可以使用宏来实现。详细信息完整描述如下: http://www.helixoft.com/blog/archives/32

您只需在 EvironmentEvents 宏部分添加一点 VB 宏并重新启动 VS。

笔记:当您第一次加载 VS 时,该路径不会显示,但每当您更改正在查看的文件时,该路径就会显示。可能有办法解决这个问题,但这似乎没什么大不了的。

其他提示

这是在线图库中专门为此工作量身定制的扩展。查看 http://erwinmayer.com/labs/visual-studio-2010-extension-rename-visual-studio-window-title/

查看最新版本 VSCommands 2010 Lite. 。它引入了一项名为友好解决方案名称的功能,您可以将其设置为在 Visual Studio 主窗口标题中显示解决方案文件路径(或其任何部分)。更多细节: http://vscommands.com/releasenotes/3.6.8.0http://vscommands.com/releasenotes/3.6.9.0

对于 2008 年,根据上面接受的答案编写宏的稍微更好的方法是使用解决方案事件而不是文档事件 - 这使您始终可以编辑标题栏,即使您没有选择文档。这是我和我的同事根据另一个宏组合在一起的宏 - 您需要更改第 15-18 行,以从源目录中提取您的分支名称,无论您如何设置。

01  Private timer As System.Threading.Timer
02  Declare Auto Function SetWindowText Lib "user32" (ByVal hWnd As System.IntPtr, ByVal lpstring As String) As Boolean
03   
04  Private _branchName As String = String.Empty
05  Private Sub SolutionEvents_Opened() Handles SolutionEvents.Opened
06      Try
07          If timer Is Nothing Then
08              ' Create timer which refreshes the caption because
09              ' IDE resets the caption very often
10              Dim autoEvent As New System.Threading.AutoResetEvent(False)
11              Dim timerDelegate As System.Threading.TimerCallback = _
12                  AddressOf tick
13              timer = New System.Threading.Timer(timerDelegate, autoEvent, 0, 25)
14          End If
15          Dim sourceIndex As Integer = DTE.Solution.FullName.IndexOf("\Source")
16          Dim shortTitle As String = DTE.Solution.FullName.Substring(0, sourceIndex)
17          Dim lastIndex As Integer = shortTitle.LastIndexOf("\")
18          _branchName = shortTitle.Substring(lastIndex + 1)
19          showTitle(_branchName)
20      Catch ex As Exception
21   
22      End Try
23  End Sub
24   
25  Private Sub SolutionEvents_BeforeClosing() Handles SolutionEvents.BeforeClosing
26      If Not timer Is Nothing Then
27          timer.Dispose()
28      End If
29  End Sub
30   
31   
32  ''' <summary>Dispose the timer on IDE shutdown.</summary>
33  Public Sub DTEEvents_OnBeginShutdown() Handles DTEEvents.OnBeginShutdown
34      If Not timer Is Nothing Then
35          timer.Dispose()
36      End If
37  End Sub
38   
39  '''<summary>Called by timer.</summary>
40  Public Sub tick(ByVal state As Object)
41      Try
42          showTitle(_branchName)
43      Catch ex As System.Exception
44      End Try
45  End Sub
46   
47  '''<summary>Shows the title in main window.</summary>
48  Private Sub showTitle(ByVal title As String)
49      SetWindowText(New System.IntPtr(DTE.MainWindow.HWnd), title & " - " & DTE.Name)
50  End Sub

确实很尴尬。将鼠标悬停在选项卡上确实是为数不多的有用的东西之一。备择方案:右键单击文件选项卡: http://weblogs.asp.net/piseth/archive/2008/11/08/find-your-file-path-in-visual-studio.aspx 看来我们必须与此有关

我使用 VSCommands 10 显示打开的解决方案文件的完整路径。

Friendly Name: {repo}
Solution Path Regex: (?<repo>.*)

现在我的主标题窗口如下所示:

c:\repositories\acme.marketplace.trunk\Acme.Marketplace.web\Acme.Marketplace.Web.sln

我可以快速浏览并看到我正在 trunk 文件夹或 rc 文件夹中工作,因为我们使用 Mercurial (Hg) 并为 trunk、rc、preprod、prod 保留单独的文件夹,如下所示:

c:\repositories\acme.marketplace.rc1
c:\repositories\acme.marketplace.rc2
c:\repositories\acme.marketplace.trunk
c:\repositories\acme.marketplace.preprod
c:\repositories\acme.marketplace.prod

如何自定义 Visual Studio 窗口标题

安装 自定义 Visual Studio 窗口标题 插入。

安装扩展后,可以在菜单中找到设置。

Tools ► Options ► Customize VS Window Title.

更多信息

Customize Visual Studio Window Title 是 Visual Studio 的轻量级扩展,它允许您更改窗口标题以包含文件夹树

enter image description here

特征

  • 与解决方案/项目文件的可配置最小和最大深度距离
  • 允许使用特殊标签来帮助解决许多其他可能的情况,其中包括 Git, MercurialTFS.

使用 MKLINK 命令创建指向现有解决方案的链接。就 Visual Studio 而言,它使用链接文件,但任何更改都会转到底层 .sln 文件。

我在这里写了一篇关于它的博客文章......

http://willissoftware.com/?p=72

对于那些无法使用 VB 方法的人(例如我),您可以使用插件:

http://visualstudiogallery.msdn.microsoft.com/f3f23845-5b1e-4811-882f-60b7181fa6d6

在VS2008旗舰版中测试过。可以在VS的选项菜单中进行配置。

如果您使用的是 VS2010 或更高版本,您可以使用扩展“Visual Studio Window Title Changer”。安装它并使用以下“窗口标题设置”表达式来显示解决方案路径:

'sln_dir + "/" + orig_title'

使用扩展管理器下载并安装扩展。扩展的详细信息以及如何使用它可以在这里找到:

https://visualstudiogallery.msdn.microsoft.com/2e8ebfe4-023f-4c4d-9b7a-d05bbc5cb239?SRC=VSIDE

相关说明:作为替代方案,对于 Visual Studio 2005,您可以使用命令“文件”->“高级保存选项”。该对话框显示当前文件的完整路径,您可以复制文本。

作为 在评论中也提到了 页脚上的文件路径 扩展也有同样的目的。

TabsStudio | $49

是一个相当不错的(尽管是付费的)VS 扩展,它提供:

  • 选项卡分组
  • 标签着色
  • 标题转换
  • 大量的定制和扩展

Tabs Studio Screenshot

页脚上的文件路径 |自由

在编辑器窗口底部显示完整文件路径

File Path On Footer Screenshot

荣誉提名:视觉工作室代码

VS代码 1.26 版实现了面包屑导航 当使用选项卡时,它会在编辑器窗口顶部的单独行中显示文件路径,或者在其自己的窗口中内联文件名。

VS Code Breadcrumbs Screenshot

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top