Display solution/file path in the Visual Studio IDE
Asked Answered
C

14

86

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

Visual C++ 6.0 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 a 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?

Calvary answered 27/8, 2008 at 15:47 Comment(4)
11 years and still not available out of the box :-/Gauzy
Preferences > Window:Title. No plugin needed. => existed since 2017 at least.Briquet
@JasonLeMonier, I can't find this setting in Visual Studio but I can find it in Visual Studio Code, are you mixing them up? Perhaps you could post a fully fleshed out answer to make it clearer. EDIT - Just noticed you did post an answer, good.Esparto
@visitors: don't search for JasonLeMoniers answer as it is indeed for VS Code - sry JLMSunny
B
25

There is not a native way to do it, but you can achieve it with a macro. The details are described here in full: How To Show Full File Path (or Anything Else) in VS 2005 Title Bar

You just have to add a little Visual Basic macro to the EvironmentEvents macro section and restart Visual Studio.

Note: The path will not show up when you first load Visual Studio, but it 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.

Bouchard answered 27/8, 2008 at 15:58 Comment(2)
File Path On Footer is also a good extensionEmad
@Emad ...but eats a line in the editor bottom (not in the status bar (you know, the blue one changing to orange when debugging)). Take it in consideration especially for little screens etc. Anyway thank you for the pointer.Unilocular
K
33

This is a extension available in the online gallery specifically tailored for this job. Checkout Labs > Visual Studio Extension: Customize Visual Studio Window Title.

Khalif answered 5/7, 2011 at 16:48 Comment(6)
Awesome. Minimalistic extension that just works. No config needed.Smattering
Works in 2015 as wellBedrail
Works in 2017 as wellAleedis
Works in 2019 as well. Optionally Re-enable the Window Title Bar or just observe your changes in the Taskbar. Tested on v16.4.2.Urogenital
Preferences > Window:Title. No plugin needed.Briquet
@JasonLeMonier The question is tagged Visual Studio, not Visual Studio Code. The two products are entirely different, like Visual Studio for Mac has nothing do to with the rest. You can thank the marketing team at MS for deliberately trying to confuse their customers/users and make their work harder.Intermezzo
B
25

There is not a native way to do it, but you can achieve it with a macro. The details are described here in full: How To Show Full File Path (or Anything Else) in VS 2005 Title Bar

You just have to add a little Visual Basic macro to the EvironmentEvents macro section and restart Visual Studio.

Note: The path will not show up when you first load Visual Studio, but it 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.

Bouchard answered 27/8, 2008 at 15:58 Comment(2)
File Path On Footer is also a good extensionEmad
@Emad ...but eats a line in the editor bottom (not in the status bar (you know, the blue one changing to orange when debugging)). Take it in consideration especially for little screens etc. Anyway thank you for the pointer.Unilocular
A
17

Check out the latest release of VSCommands 2010 Lite. It introduced a feature called Friendly Solution Name where you can set it to display the solution file path (or any part of it) in Visual Studio's main window title.

More details: http://vscommands.com/releasenotes/3.6.8.0 and http://vscommands.com/releasenotes/3.6.9.0

Anticlerical answered 29/4, 2011 at 12:21 Comment(3)
vs2013 version : visualstudiogallery.msdn.microsoft.com/…Messere
All links (domain vscommands.com) seems to be broken (times out).Ghyll
However, there is VSCommands for Visual Studio 2010. Is it the same?Ghyll
G
5

For Visual Studio 2008, a slightly better way to write the macro from the accepted answer 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.

Private timer As System.Threading.Timer

Declare Auto Function SetWindowText Lib "user32" (ByVal hWnd As System.IntPtr, ByVal lpstring As String) As Boolean

Private _branchName As String = String.Empty

Private Sub SolutionEvents_Opened() Handles SolutionEvents.Opened
    Try
        If timer Is Nothing Then
            ' Create timer which refreshes the caption because
            ' IDE resets the caption very often
            Dim autoEvent As New System.Threading.AutoResetEvent(False)
            Dim timerDelegate As System.Threading.TimerCallback = _
                AddressOf tick
            timer = New System.Threading.Timer(timerDelegate, autoEvent, 0, 25)
        End If
        Dim sourceIndex As Integer = DTE.Solution.FullName.IndexOf("\Source")
        Dim shortTitle As String = DTE.Solution.FullName.Substring(0, sourceIndex)
        Dim lastIndex As Integer = shortTitle.LastIndexOf("\")
        _branchName = shortTitle.Substring(lastIndex + 1)
        showTitle(_branchName)
    Catch ex As Exception

    End Try
End Sub


Private Sub SolutionEvents_BeforeClosing() Handles SolutionEvents.BeforeClosing
    If Not timer Is Nothing Then
        timer.Dispose()
    End If
End Sub


''' <summary>Dispose the timer on IDE shutdown.</summary>
Public Sub DTEEvents_OnBeginShutdown() Handles DTEEvents.OnBeginShutdown
    If Not timer Is Nothing Then
        timer.Dispose()
    End If
End Sub


'''<summary>Called by timer.</summary>
Public Sub tick(ByVal state As Object)
    Try
        showTitle(_branchName)
    Catch ex As System.Exception
    End Try
End Sub


'''<summary>Shows the title in main window.</summary>
Private Sub showTitle(ByVal title As String)
    SetWindowText(New System.IntPtr(DTE.MainWindow.HWnd), title & " - " & DTE.Name)
End Sub
Garaway answered 3/5, 2011 at 14:8 Comment(0)
H
4

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.

Menu ToolsOptionsCustomize 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 minimum and maximum 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.
Hurryscurry answered 21/6, 2017 at 13:12 Comment(3)
While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. Please read this how-to-answer for providing quality answer.Bourgogne
Preferences > Window:Title. No plugin needed.Briquet
@JasonLeMonier No such option exists in Visual Studio, which is the IDE that the OP is asking about.Gaptoothed
H
3

It's awkward indeed. Hovering on the tab is indeed one of the few things useful.

Alternative: right click on the file tab: Find your File Path in Visual Studio. It seems we have to do with that.

Hartsfield answered 16/9, 2009 at 13:42 Comment(0)
P
2

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
Proteiform answered 27/6, 2012 at 10:49 Comment(1)
Is it the same as VSCommands for Visual Studio 2010?Ghyll
R
2

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

Rumpus answered 6/5, 2018 at 14:2 Comment(0)
G
2

TabsStudio | US$49

It is a pretty good (although paid) Visual Studio extension that provides:

  • Tab grouping
  • Tab coloring
  • Title transformation
  • Lots of customization and extensions

Tabs Studio Screenshot

File Path On Footer | Free

It displays the full file path on the bottom of the editor window:

File Path On Footer Screenshot

Honorable Mention: Visual Studio Code

Visual Studio 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.

Visual Studio Code Breadcrumbs Screenshot

Gleeful answered 29/8, 2018 at 16:49 Comment(0)
P
1

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

Probationer answered 9/12, 2008 at 19:51 Comment(0)
W
1

Use the MKLINK command to create a link to your existing solution. As far as Visual Studio is concerned, it's 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

Washington answered 3/5, 2012 at 21:38 Comment(2)
The link is broken ("We can’t connect to the server at www.willissoftware.com."). Domain expired?Ghyll
This answer is not very useful with the broken link.Ghyll
O
1

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

Customize Visual Studio Window Title

It was tested it in Visual Studio 2008 Ultimate. You can configure it in the Options menu of Visual Studio.

Olaolaf answered 4/5, 2012 at 8:36 Comment(1)
Preferences > Window:Title. No plugin needed.Briquet
P
0

If you are using Visual Studio 2010 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

Predestination answered 13/4, 2015 at 2:59 Comment(2)
The link is broken (404).Ghyll
Preferences > Window:Title. No plugin needed.Briquet
B
-1

File > Preferences > Settings >> Window:Title

I just changed ${activeEditorShort} => ${activeEditorLong}

within the setting: ${dirty}${activeEditorLong}${separator}${rootName}${separator}${appName}

Worked immediately when I clicked a file.

Great help right in the setting ...

Window: Title -- Controls the window title based on the active editor. Variables are substituted based on the context:

${activeEditorShort}: the file name (e.g. myFile.txt).

${activeEditorMedium}: the path of the file relative to the workspace folder (e.g. myFolder/myFileFolder/myFile.txt).

...

Visual Studio Code Version: 1.56.2 Date: 2021-05-12

I found one reference saying this existed since 2017.

Briquet answered 4/6, 2021 at 16:46 Comment(1)
The question is for Visual Studio, not Visual Studio Code.Esparto

© 2022 - 2024 — McMap. All rights reserved.