Labs > Visual Studio Extension: Customize Visual Studio Window Title

Désolé, cet article est seulement disponible en English. Pour le confort de l’utilisateur, le contenu est affiché ci-dessous dans une autre langue. Vous pouvez cliquer le lien pour changer de langue active.


This lightweight extension allows changing the window title of Visual Studio to include a folder tree with a configurable min depth and max depth distance from the solution/project file, and the use of special tags to help with many other possible scenarios (Git, Mercurial, TFS…).

Solution-specific overriding rules are available as well to cover virtually any possible renaming needs.

It can also be configured so that the rules apply only when at least two instances of Visual Studio are running with the same window title.

With default settings, SolutionFolder – Microsoft Visual Studio (Administrator) will be rewritten as SolutionFolderParent\SolutionFolder – Microsoft Visual Studio (Administrator)\*.

The following special tags are available:

  • [documentName] Active document or, if no active document, window name;
  • [projectName] Active project name;
  • [startupProjectsNames] Startup project(s) name(s), separated with ‘ & ‘ if multiple;
  • [startupProjectsNames:X] Startup project(s) name(s), separated with X if multiple (recommended values: ‘ & ‘, ‘, ‘ or ‘ | ‘ without quotes);
  • [documentProjectName] Active document project name (if the document is part of a loaded project);
  • [documentProjectFileName] Active document project file name (if the document is part of a loaded project);
  • [solutionName] Active solution name;
  • [documentPath] Active document full path or, if no active document, window name;
  • [documentPath:X] Active document path element at the specified index (e.g. for C:\F1\Foo.cs, [documentPath:0] = C:\, [documentPath:1] = C:\F1);
  • [documentPath:X:Y] Active document path segment over the specified range (e.g. for C:\F1\Foo.cs, [path:0:2] = C:\F1\Foo.cs, [path:2:0] = Foo.cs\F1\C:);
  • [documentParentPath:X] Active document path parent element at the specified index (e.g. for C:\F1\Foo.cs, [parent:0] = Foo.cs [parent:1] = F1);
  • [documentParentPath:X:Y] Active document path parent segment over the specified range (e.g. for C:\F1\Foo.cs, [parent:1:0] =F1\Foo.cs, [parent:0:1] = Foo.cs\F1);
  • [env:X] Environment variable X for current Visual Studio process;
  • [path] Current solution full path or, if no solution open, document full path or, if no active document, window name;
  • [path:X] Path element at the specified index (e.g. for C:\F1\MySolutionFolder\MySolution.sln, [path:0] = C:\, [path:1] = C:\F1);
  • [path:X:Y] Path segment over the specified range (e.g. for C:\F1\MySolutionFolder\MySolution.sln, [path:0:2] = C:\F1\MySolutionFolder, [path:2:0] = MySolutionFolder\F1\C:);
  • [parentPath] Current solution path or, if no solution open, document path, with depth determined by « Farthest parent folder depth » and « Closest parent folder depth » settings;
  • [parent:X] Path parent element at the specified index (e.g. for C:\F1\MySolutionFolder\MySolution.sln, [parent:0] = MySolution.sln [parent:1] = MySolutionFolder);
  • [parent:X:Y] Path parent segment over the specified range (e.g. for C:\F1\MySolutionFolder\MySolution.sln, [parent:2:1] =F1\MySolutionFolder, [parent:1:2] = MySolutionFolder\F1);
  • [ideName] Name of the IDE (e.g. Microsoft Visual Studio), including elevation suffix if applicable (e.g.  » (Administrator) »);
  • [elevationSuffix] Elevation suffix if applicable (e.g.  » (Administrator) »), otherwise empty;
  • [platformName] Current platform name (e.g. x86);
  • [configurationName] Current configuration name (e.g. Release);
  • [vsMajorVersion] Major version of Visual Studio (e.g. 11, 12, 14, 15…);
  • [vsMajorVersionYear] Major version of Visual Studio, in year form (e.g. 2012, 2013, 2015, 2017…);
  • [vsProcessID] Process ID of Visual Studio;
  • [gitBranchName] Current Git branch name. Make sure Git’s executable directory is added to the Windows PATH variable or specify its location in settings;
  • [hgBranchName] Current Mercurial branch name. Make sure Mercurial’s executable directory is added to the Windows PATH variable or specify its location in settings;
  • [workspaceName] Team Foundation Server (TFS) workspace name of the currently loaded solution;
  • [workspaceOwnerName] Team Foundation Server (TFS) workspace owner name of the currently loaded solution.
  • [debuggedProcessesArgs] Arguments of the processes currently debugged (including the executable file name before each set of arguments if more than 1 process).

The symbol ‘\*’ will be added at the end automatically to identify that the title is being improved (can be configured in settings).

This is particularly useful when branching a solution/project: it becomes possible to easily identify which branch you are working on, in the case where both would have the same solution/project name.

It is possible to allow solution-specific settings overrides in two different ways:

  1. By enabling this option in the settings, and placing a ‘MySolution.sln.rn.xml’ file in the same directory as the MySolution.sln file to which it should refer to. The file should be in xml format containing a single CustomizeVSWindowTitle/SettingsSet element, which attributes can be the following:SolutionName, FarthestParentDepth, ClosestParentDepth, PatternIfDesignMode, PatternIfBreakMode, PatternIfRunningMode, AppendedString.
  2. By enabling this option in the settings, and specifying a « Global solution-specific settings overrides file path ». This file should be in xml format containing multiple CustomizeVSWindowTitle/SettingsSet elements as for .sln.rn.xml files, with the addition of a Path attribute or child node(s) to specify to which solution path or solution name each SettingsSet is applicable (wildcards are supported). Overrides from this global file take precedence over those found in .sln.rn.xml files.

If useful, patterns may therefore be completely hardcoded on a per solution basis.

To automatically generate and open such xml files, go to the « Solution-specific overrides » section of the extension settings. There, click on either the « Open solution config » or « Open global config » convenience buttons. The files will be pre-populated with your current configuration to make further customization easier, and will be opened for edition as any other code file right in Visual Studio.

All available tags are listed inside the extension settings in Visual Studio > Tools > Options… > Customize VS Window Title > Supported tags. They can also be easily inserted in each pattern field by clicking on the dropdown arrow at the right of each field, and then on the  yellow button.

Feature requests are welcome here. Official GitHub repository here. Contributions are welcome. More screenshots are available in this review by Sergey Vlasov.

You can install the extension from within Visual Studio directly or download the VSIX installable package from the Visual Studio Marketplace.

73 commentaires à l'article “Visual Studio Extension: Customize Visual Studio Window Title”

  1. Yannik
    5 juin 2012 | 15:50

    many thanks, exactly what I was looking for!!

  2. Matt
    1 décembre 2012 | 18:04

    First off. Thanks and great job!

    Not sure if you’re aware (or care :)), but when no project is loaded, granted should rarely happen, the title bar fills with « – * – * – * – * ». Text find/replace issue?

    Options:
    False
    1
    1
    2
    False

    Defaults for all the rest.

  3. Matt
    18 janvier 2013 | 10:01

    Just an update. The new version appears to fix starting with no solution running, but if you open a solution and then close it, the problem starts again. This is under 2010 with SP1; same settings as before. It never removes the solution path and then starts repeating « Microsoft Visual Studio (Administrator) * –  » over and over. This was as of the version available 1/10/2013.

    Again, thanks for the great extension. I can’t tell you how often it has helped me save time and be able to work more comfortably with multiple revisions.

  4. argrithmag
    30 janvier 2013 | 18:23

    thanks for the plugin. Could you do the same directory change in the recent projects? having multiple version of the same project means i have to hover over each one to see the proper directory….

    thanks!

  5. John
    4 février 2013 | 16:40

    Can you give an option to not show the * after the title? My mind keeps telling me there are unsaved changes when I see that out of the corner of my eye 🙂

    Great plugin, thanks!

  6. Inger Marie B. Jakobsen
    14 mars 2013 | 09:28

    This extension seems like just what I am looking for, but I really never did use an extension with options before. So I am a bit at a loss. Where and how do I set up the extension to show me the full path?

    I need to see the full path to be able to differentiate, because I have Projects\Main\ and Projects\Release\.

  7. 14 mars 2013 | 09:34

    Hi Inger Marie, you can adjust the options in « Tools » > « Options » > « Rename VS Window Title ». There you probably just need to play with the options labeled « Closest parent folder depth » and « Farthest parent folder depth ».

    Cheers

  8. Inger Marie B. Jakobsen
    19 mars 2013 | 08:33

    Thanks a lot. It works! This add-on is a great help for me

  9. Bill S
    18 avril 2013 | 17:02

    This is a great extension. Love being able to set properties to get it to look just right for me.

    Thanks.

  10. Maks Y
    12 juin 2013 | 19:35

    Must have extension if you work with multiple source code branches. Thanks

  11. Peter DeSimone
    10 juillet 2013 | 20:45

    After install VS 2012 Update 3, this extension is disabled. How can I re-enable it? The Enable button is disabled.

  12. 10 juillet 2013 | 23:23

    Hi Peter,

    I do not have this problem. Maybe try to restart Visual Studio or your computer.
    Best,

    Erwin

  13. Xavier
    21 août 2013 | 15:59

    When you have a query open (Team Explorer) it shows the ID of the query instead of the name…

  14. Toggle
    17 janvier 2014 | 17:16

    I’m running VS 2013 (12.0.21005.1) with .NET Framework 4.5.50938 the activity log says « CreateInstance failed for package… » The extension won’t load. The error message is: Could not load file or assembly ‘Microsoft.VisualStudio.Shell.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified.
    Any thoughts? Thanks!

  15. 21 janvier 2014 | 07:11

    I replied to you by email.

  16. Gabi
    7 février 2014 | 08:42

    I just updated to version 2.6.0. I use VS 2010 10.0.40219.1 and after this update Rename VS Window Title extension stopped working. If I enable debug mode I’m getting this exception:

    RenameVSWindowTitle: UpdateWindowTitle exception: System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.VisualStudio.TeamFoundation.VersionControl, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified.

    What can I do?

    Thanks!

  17. Thomas
    24 mars 2014 | 08:18

    I’m running VS2012 but cannot laod your package. The Activitiy Log says:
    CreateInstance failed for package [ErwinMayerLabs.RenameVSWindowTitle.RenameVSWindowTitle, RenameVSWindowTitle, Version=1.3.0.0, Culture=neutral, PublicKeyToken=ceec2b7720c0179d]

    You mention above that you replied to a similar error message to a user named Toggle on Jan. 21, 2014, by email. Do you have a solution for this?
    Thank you!

  18. 24 mars 2014 | 08:26

    Hi Thomas,

    I do not have such problem with a similar set-up (same VS version + .NET 4.5.51641).
    Can you try on another machine maybe? Uninstalling and reinstalling the extension?
    Are you running Visual Studio Express edition (it is not compatible with it)?

  19. Thomas
    24 mars 2014 | 09:32

    Uninstalling the extension and installing it again using a CMD box as administrator with the command
    « C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\VSIXInstaller.exe » /quiet /admin D:\Downloads\RenameVSWindowTitle.vsix
    did the job; the problem did not reappear even after rebooting the computer.
    We are using the professional edition of VS 2012.

  20. Matt
    8 avril 2014 | 19:19

    This is very useful! I encourage everyone to donate, as well.

    Like John above, the asterisk puts me a little on edge, thinking I haven’t saved. Is there a way to eliminate that, or is it a by-product of modifying the title?

    Also, Erwin, you commented on StackOverflow about how setting the title with the win32 api won’t work correctly. So how are you doing it? With the DTE model or?

    Thanks!

  21. 9 avril 2014 | 10:48

    Hi Matt, thank you for your donation! This is very much appreciated.

    Actually it is already possible to configure the asterisk in the Options: just change the parameter « Appended string » to whatever you like (but it should be at least one distinct character).

    To set the title, I am using the following piece of code, which you can also see in the Codeplex repository:

    System.Windows.Application.Current.MainWindow.Title = "Hello world;

  22. Matt
    9 avril 2014 | 17:44

    Cool, thanks Erwin. I changed my appended string to « 🙂 »

  23. Igor
    30 avril 2015 | 09:29

    Great addin!!! Thanks.
    Is it posible to add special tag for VS version (e.g. 2012, 2013, 2015CTP)? All modern VS vesions looks very similar and this is important (for me) to distinguish.

  24. 30 avril 2015 | 09:42

    Hi Igor, it should be possible, but isn’t it sufficient to have a different icon for each version of Visual Studio?

  25. Igor
    30 avril 2015 | 11:55

    Hi Erwin,
    do you mean that 1) VS have different styles for icons or 2) that different VS versions don’t stack together on taskbar or 3) you wonder why I need to distinguish :)?

    1) Icons of 2015CTP and 2013 looks me identical, 2012 also have pretty similar icon as far as I remember (I don’t have one currently).
    2) I am very unorganized and have tons of visual studio’s open so I see 2 stacks with similar icons in taskbar.
    3) 2015CTP has nice new features that I like to use with some projects but I still need 2013 for other project, sometimes I accidentally open project in a wrong version (or I just want to be sure before 10 minutes long build). My current solution is to press Alt+H,A to get the about window and if I could see it in title will save me additional 20 seconds a day 🙂
    Thanks for plugin again.

  26. 30 avril 2015 | 20:10

    Hi Igor, your wish has come true. I have just released a new version with support of the following tags:
    – [vsMajorVersion] Major version of Visual Studio (e.g. 9, 10, 11, 12, 14…);
    – [vsMajorVersionYear] Major version of Visual Studio, in year form (e.g. 2008, 2010, 2012, 2013, 2015…);
    Enjoy. You now have 20 more seconds per day to make the world better :).

  27. Igor
    1 mai 2015 | 11:22

    Cool, thank you 🙂

  28. Ronald
    4 mai 2015 | 07:30

    Hi Erwin,

    Great plugin that makes my life a lot easier, but v2.8.1 crashes on startup with my vs2012 installation.

    From the ActivityLog.xml file:
    76 ERROR CreateInstance failed for package [ErwinMayerLabs.RenameVSWindowTitle.RenameVSWindowTitle, RenameVSWindowTitle, Version=1.3.0.0, Culture=neutral, PublicKeyToken=ceec2b7720c0179d] {5126C493-138A-46D7-A04D-AD772F6BE159} 80070002 VisualStudio 2015/05/04 06:24:12.602
    77 ERROR End package load [ErwinMayerLabs.RenameVSWindowTitle.RenameVSWindowTitle, RenameVSWindowTitle, Version=1.3.0.0, Culture=neutral, PublicKeyToken=ceec2b7720c0179d] {5126C493-138A-46D7-A04D-AD772F6BE159} 80004005 – E_FAIL VisualStudio 2015/05/04 06:24:12.602

  29. Ronald
    4 mai 2015 | 07:39

    My post was just a little too quick 🙂

    Fixed it by reinstalling as admin, as suggested by Thomas on march 24, 2014. Can you get the installer to ask for admin rights perhaps?

  30. 4 mai 2015 | 07:48

    Hi Ronald, did you install the extension by downloading the VSIX as a file instead of from the extension manager within Visual Studio? It seems to be the same problem as the one described here:
    http://blogs.telerik.com/telerik_vsxteam_blog/posts/11-05-02/vsix-package-deployment-and-users-in-the-same-machine.aspx
    Not sure if there is anything simple I could do as I have no control over the VSIX installer (and admin rights are not theoretically required).

  31. hepek
    7 mai 2015 | 15:25

    hi Erwin,

    this is a great extension, thank you.
    I have a folder structure like this:
    DEV branch: C:\OnePlace\DEV\WebSite (folder contains .sln file)
    STAGE branch: C:\OnePlace\STAGE\WebSite (folder contains .sln file)

    I would like to display title like this: « OnePlace DEV », or « OnePlace STAGE ». basically I need to include parent.parent folder, in this case DEV or STAGE

    is that possible? thank you

  32. Graham
    8 mai 2015 | 12:17

    hi Erwin

    Looks like the [workspaceName] tag may no longer be working in 2.8.2 (in VS 2012)

    I just installed 2.8.2 and it is no longer working for me!

    thanks

  33. 8 mai 2015 | 13:34

    Hi Graham, thanks for your feedback. I have sent you an email.

  34. Bash
    24 juillet 2015 | 14:10

    Not working for me (VS 2013), the same issue as Graham!

  35. 30 septembre 2015 | 08:28

    Hi Bash, have you tried version 3.0?

  36. Rory
    23 août 2016 | 16:47

    Thanks Erwin, this is really handy for me as I’ve multiple branches and was sick of making mistakes as to which branch I was in or having to check the file properties.

  37. 20 septembre 2016 | 15:48

    Love it. Just started with the pattern: « [solutionName] in [parent3]/[parent2] », since I am using a two-level branch naming convention.

  38. Peter
    15 novembre 2016 | 16:20

    This use to be working fine but recently in VS 2015 Pro it gets disabled automatically. If I enable it appears to work and then at some random time (restart of VS it gets disabled again).

    Currently installed version is 3.3.5 on VS v14.0.25431.01 Update 3.

  39. Olag
    24 novembre 2016 | 15:09

    Same problem. VS Enterprise 2015 (v14.0.25431.01 Update 3). On restart of VS it gets disabled.

  40. 27 novembre 2016 | 20:14

    Thanks. I have been looking for a way to identify the GIT branch that I am working on. This does what I need.

    I hope that a 2017 compatible is either in the works or planned.

  41. Beat
    29 novembre 2016 | 17:09

    Same problem. VS Enterprise 2015 (v14.0.25431.01 Update 3). On restart of VS it gets disabled.

  42. 3 janvier 2017 | 16:40

    Hi Beat,

    Do check the following question (and solution) on StackOverflow, it seems related to a similar issue:

    http://stackoverflow.com/questions/35203647/updating-visual-studio-2015-extensions-end-up-disabled

    Let me know if you still encounter problems as there is nothing in the latest releases that could be causing such behavior (all exceptions are caught and simply printed in the logs visible in the Output window).

  43. 3 janvier 2017 | 16:40

    Hi Mike, yes, a 2017-compatible version will be released before RTM.

  44. Scott
    2 février 2017 | 23:37

    Simple yet brilliant. This should have been released as part of Visual Studio. Thank you.

  45. Richard
    7 novembre 2017 | 16:36

    Hi,

    is there a way to show TFS branch?

    Thanks

    Richard

  46. 11 novembre 2017 | 20:43
  47. 20 novembre 2017 | 21:38

    Erwin,

    Thanks we are just getting into using TFS branching so very glad you made this extension available! A co-worker asked if there might be a way (future version) to change the Visual Studio color theme depending on some rule like if branch contains \Main\ one color and \Dev\ another color. We configure our IBM midrange terminal sessions similarly so we easily know if we are logged onto the development server or the production one. The title is great and will work but the color theme would be totally awesome!

  48. 21 novembre 2017 | 04:42

    @Bill, unfortunately as per https://stackoverflow.com/questions/31377442/changing-color-theme-within-a-visual-studio-extension the color scheme doesn’t seem to be exposed as a property. I just tried again with VS2017 and it is not better supported. It is certainly not impossible (see the SO answer about importing and exporting settings), but it’ll likely be slow to apply anyway, and it seems the color scheme is shared across ALL opened instances of Visual Studio (you can try changing the setting yourself to see), so I don’t think it will have much value. Thanks for the suggestion anyway.

  49. Ted
    6 septembre 2018 | 16:51

    Hi Erwin,

    The asterisk seems to be out of place: My title bar reads « RootDir\SolutionName – Microsoft Visual Studio * ». Being at the very end, this asterisk gives the impression that I have unsaved work. Assuming this isn’t the intention, perhaps this is something you could look into fixing at some point?

    Thanks for the helpful extension!
    -Ted

  50. 6 septembre 2018 | 17:21

    Hi Ted, the symbol at the end (which is necessary to be able to identify window titles which have been rewritten) can be customized to whichever other symbol you might prefer in the extension settings :).

  51. 7 décembre 2018 | 17:55

    Hi,

    I’ve been using your plugin for years but it looks like it doesn’t work for VS 2019.

    Thanks,
    Dominik

  52. 7 décembre 2018 | 18:05

    Hi Dominik,

    Thanks for your message. VS 2019 was supposed to even remove the whole title bar (many complained, not sure if it’ll be back or not), so I have not even tried to check compatibility yet. I am waiting for the first RC to come out as previews are notoriously unstable and subject to change. But PRs are always welcome if you test it and manage to make it compatible!

  53. Dan
    18 mars 2019 | 19:10

    Thanks for this tool … I love it. Sadly, the update yesterday blew away all my settings. It took some time figure it all out again. I’ll turn off « Automatically update this extension » from now on.

    Thanks again for the extension!

  54. 18 mars 2019 | 19:22

    Hi Dan, can you try updating again to the latest version? It should hopefully bring back your settings. I had updated a namespace while refactoring, and it seems it has caused the settings not to be deleted but considered as different ones, hence what you’ve seen. So I have reverted the namespace and it should take care of it. Do let me know if it indeed resolves your issue!

  55. Klaus
    19 mars 2019 | 06:35

    Hi Erwin,

    i just installed the latest version on VS2019 RC2. It seems not to work. No matter which folder depth i configure, only the solution name is displayed.

  56. 19 mars 2019 | 07:41

    Hi Klaus, VS 2019 RC2 does not display the title bar, so it won’t work. What you’re seeing is only the solution name, and AFAIK there is no way to change it. However Microsoft has said it’ll be possible to re-enable the title bar again in the first GA release coming next month. See this thread for more details: https://developercommunity.visualstudio.com/idea/381901/do-not-remove-title-bar-from-visual-studio-2019.html

  57. Wim
    20 mars 2019 | 09:44

    Would it be possible to add a [gitRepositoryName] tag?

  58. 20 mars 2019 | 10:16

    Hi Wim, it’d be best to submit this feature request in Github. Isn’t the repository name usually the same as the solution name?

  59. Andrea
    6 juin 2019 | 09:31

    Hi Erwin, it’s not working on vs2019… 🙁
    Personally I like the vs2019 « no title bar » feature , is it possibile to customize the displayed solution name?

  60. 6 juin 2019 | 09:41

    Hi Andrea, it is actually working in VS 2019, you just need to enable the title bar in the options. AFAIK it is not trivial to customize the displayed solution name.

  61. Mick
    31 juillet 2019 | 23:52

    This add-in is great and solves a big problem with identifying which branch is loaded!

    Thanks!

  62. Laurent
    28 octobre 2019 | 14:10

    Very useful!
    Thanks.

  63. Daniel
    6 janvier 2020 | 18:28

    Even though this extension can’t alter the displayed solution in VS2019, it does still affect the window title that shows up when switching applications/instances. So it’s less useful than it used to be (if you don’t want to enable the title bar), but still worth having.

    Hopefully, at some point Microsoft will provide a hook to change the displayed solution, as well.

  64. Igor
    22 juin 2020 | 08:20

    Cool update! There is no more tfsBranchName.

  65. 22 juin 2020 | 09:31

    Hi Igor, what do you mean with « there is no more tfsBranchName »?

  66. Bob
    30 juillet 2020 | 07:17

    Hi Erwin,
    very nice Plugin! Helps me keeping track of the current workspace and solution when working with different VS instances.
    Displaying the current TFS changeset number would put the cherry on the cake.
    But still, excellent work!

  67. David Cowan
    16 novembre 2020 | 23:49

    Is it possible to use the path specifier parameter with `gitBranchName` so I can strip off the leading parts of the path (if there are any).
    i.e.
    [gitBranchName] = dave/prototype/test-1
    [gitBranchName:0] = test-1

  68. 17 novembre 2020 | 05:12

    @David, it is not possible at the moment, but feel free to submit a pull request on GitHub (or add this as a feature request). Shouldn’t be too hard to implement by reusing the same logic as for other paths.

  69. ruihong
    1 juillet 2021 | 03:51
  70. Joris
    2 novembre 2021 | 10:44

    Hi Erwin!

    Love the plugin. If it’s not too much effort: could you also make a 64bit build of it so it can be used in VS2022? I miss it 🙁

  71. 4 novembre 2021 | 21:19

    @Joris, yes planning to release a version for VS 20222 by the end of the year.

  72. Sam Marrocco
    20 novembre 2021 | 15:30

    Any chance of making the source available?

  73. 21 novembre 2021 | 20:07

    @Sam, the source code is available here: https://github.com/mayerwin/vs-customize-window-title

Laisser un commentaire