Question

I frequently work with multiple instances of Visual Studio, often working on different branches of the same solution.

VC6 used to display the full path of the current source file in its title bar, but Visual Studio 2005 doesn't appear to do this. This makes it slightly more awkward than it should be to work out which branch of the solution I'm currently looking at (the quickest way I know of is to hover over a tab so you get the source file's path as a tooltip).

Is there any way to get the full solution or file path into the title bar, or at least somewhere that's always visible so I can quickly tell which branch is loaded into each instance?

Was it helpful?

Solution

There is not a native way to do it, but you can achieve it with a macro. The details are described here in full: http://www.helixoft.com/blog/archives/32

You just have to add a little VB Macro to the EvironmentEvents macro section and restart VS.

Note: The path will not show up when you first load VS, but will whenever you change which file you are viewing. There is probably a way to fix this, but it doesn't seem like a big deal.

OTHER TIPS

This is a extension available in the online gallery specifically tailored for this job. Checkout http://erwinmayer.com/labs/visual-studio-2010-extension-rename-visual-studio-window-title/

Check out latest release of VSCommands 2010 Lite. It introduced a feature called Friendly Solution Name where you can set it to display solution file path (or any part of it) in Visual Studio main window title. More details: http://vscommands.com/releasenotes/3.6.8.0 and http://vscommands.com/releasenotes/3.6.9.0

For 2008, a slightly better way to write the macro from the accepted answer above is to use the Solution events instead of the document ones - this lets you always edit the title bar, even if you don't have a document selected. Here's the macro my coworker and I put together based on the other one - you'll want to change lines 15-18 to pull your branch name from the source directory for however you're set up.

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

It's awkward indeed. Hovering on the tab is indeed one of the few things useful. Alternatives: right click on the file tab : http://weblogs.asp.net/piseth/archive/2008/11/08/find-your-file-path-in-visual-studio.aspx Seems we have to do with that

I am using VSCommands 10 to show the full path of the solution file open.

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

Now my main title window looks like this:

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

I can quickly glance and see that I am working in the trunk folder or a rc folder because we use Mercurial (Hg) and keep separate folders for trunk, rc, preprod, prod like this:

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

How to customise the Visual Studio window title

Install the Customize Visual Studio Window Title plugin.

After installing the extension, the settings can be found in the menu.

Tools ► Options ► Customize VS Window Title.

More information

Customize Visual Studio Window Title is a lightweight extension to Visual Studio, which allows you to change the window title to include a folder tree

enter image description here

Features

  • A configurable min and max depth distance from the solution/project file
  • Allows the use of special tags to help with many other possible scenarios, which include Git, Mercurial and TFS.

Use the MKLINK command to create a link to your existing solution. As far as Visual Studio is concerned its working with the link file, but any changes go to the underlying .sln file.

I wrote a blog entry here about it...

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

For the people that didn't get the VB method to work (like me) you can use a plugin:

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

Tested it in VS2008 Ultimate. You can config it in the Options menu of VS.

If you are using VS2010 or above you can you the extension "Visual Studio Window Title Changer". Install this and use the following 'Window Title Setup' expression to display the solution path:

'sln_dir + "/" + orig_title'

Use the extension manager to download and install the extension. Details of the extension and how to use it can be found here:

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

Related note: As an alternative, for Visual Studio 2005 you can use the command File -> Advanced Save Options. The dialog displays the full path of the current file, and you are able to copy the text.

As Dan also mentioned it in a comment, the File Path On Footer extension serves the same purpose.

TabsStudio | $49

Is a pretty good (although paid) VS Extension that provides:

  • Tab Grouping
  • Tab Coloring
  • Title Transformation
  • Lots of customization & Extension

Tabs Studio Screenshot

File Path On Footer | Free

Displays the full file path on the bottom of the editor window

File Path On Footer Screenshot

Honorable Mention: Visual Studio Code

VS Code version 1.26 implemented breadcrumbs which displays the file path in a separate row at the top of the editor window when using tabs or inline the file name when in its own window.

VS Code Breadcrumbs Screenshot

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top