Little great things about Visual Studio 2019

Mads Kristensen

A few days ago, we announced the general availability of Visual Studio 2019. But I’ve been using Visual Studio 2019 exclusively since the first internal build – long before the release of Preview 1 in December of 2018. During this time, there has been a lot of little features that have put a smile on my face and made me more productive.

I want to share a few of them with you since they are not all obvious and some require you to change some settings. Let’s dive in.

Clean solution load

When a solution is closed, its state is saved so that next time you open it, Visual Studio can restore the collapsed/expanded state of projects and folders in Solution Explorer and reopen the documents that were left open. That’s great but I prefer a clean slate when I open solutions – no files open and all the tree nodes collapsed in Solution Explorer.

I wrote the Clean Solution extension to provide this behavior in previous version of Visual Studio. This feature is now native to Visual Studio 2019 and can be enabled with two separate checkboxes. Go to search (Ctrl+Q) and type in “load” to find the Projects and Solutions > General options page.

Uncheck both the Reopen documents on solution load and Restore Solution Explorer project hierarchy on solution load checkboxes.

An added benefit from unchecking these two checkboxes is that solutions will load faster too, because of the eliminated overhead from restoring state. Win-win.

Git pull from shortcut

I do a lot of work with GitHub repos and I often take pull requests from people. That means I must make sure to do a git pull before I make any subsequent commits. But, as it turns out repeatedly, this is something I tend to forget. The result is that I end up with merge conflicts and other nuisances.

The only way to do git pull in the past was to either use Team Explorer, the command line, or an external tool. What I really wanted was a keyboard shortcut from within Visual Studio that did it for me.

Previously, Team Explorer’s pull command was not a command you could assign keyboard shortcuts to but now it is. Go to search (Ctrl+Q) and type “keyboard” to find the Environment > Keyboard options page. From there, find the Team.Git.Pull command from the list. Then assign any shortcut to it and hit the OK button. I chose to use Ctrl+Shift+P.

To automatically perform a git pull upon solution load, try out the free Git Pull extension.

Code Cleanup for C#

Keeping source code neatly formatted and ensuring coding styles are consistent is something I’ve never been good at. The new Code Cleanup feature is a huge help in keeping my code neat and tidy since I have configured it to run all the fixers by default.

To do that, go to the Code Cleanup menu sitting in the bottom margin of the editor window and click Configure Code Cleanup.

In the dialog, select all the fixers one by one from the bottom pane and hit the up-arrow button to move them up into the top. Then hit OK.

Now all fixers will run every time you perform a Code Cleanup. Simply hit Ctrl+K, Ctrl+E to execute. The result is a nicely formatted document with a bunch of coding style rules applied, such as added missing braces and modifiers. Voila!


IntelliCode is a new feature that augments the IntelliSense completions based on the context you’re in using advanced machine learning algorithms. That proves useful for many scenarios including when you are exploring new interfaces or APIs. I write a lot of Visual Studio extensions and the API surface is so big that there are parts of it I have never used. When I’m exploring a new part of the Visual Studio API, I find it very helpful to have IntelliCode guide me through how to use it.

To enable this powerful feature, you can download IntelliCode from the Visual Studio Marketplace and install the extension.

IntelliCode works for C#, C++ and XAML.

See content of Clipboard Ring

Every time you copy (Ctrl+C) something in Visual Studio, it is being stored in the Clipboard Ring. Hitting Ctrl+Shift+V allows you to cycle through the items in the Clipboard ring and paste the item you select. I find it very useful to keep multiple things in the clipboard at once and then paste the various items to specific locations.

In Visual Studio 2019, the Clipboard Ring now shows a visual preview of its content when hitting Ctrl+Shift+V. That makes it easier than ever to navigate through the copy history and select the right item to paste.

New C# Refactorings

There are lots of new and highly useful refactorings in C# that I’ve come to depend on every single day. They show up as suggestions in the light bulb and include moving members to interface or base class, adjusting namespaces to match folder structure, convert foreach-loops to Linq queries, and a lot more.

To learn more about the new refactorings and other C# features in Visual Studio 2019, check out this post on the .NET blog.

Git Stash

Having the ability to stash away some work for future use is super helpful. Git Stash is what gives me that ability without having to create a new branch. If you’re familiar with TFS, you can think of Git Stash as a shelveset.

The best part is that I can manage all my stashes inside the Team Explorer window. They are easy to create and apply, and I’ve been using them a lot more after Visual Studio now natively supports them.

Try Visual Studio 2019

These were just a few of the many small improvements found throughout Visual Studio 2019 that I find particularly useful. Please share any tips or improvements you’ve found helpful in the comments below!


Comments are closed. Login to edit/delete your existing comments

  • Jens Samson

    Too bad, once again C# gets the spotlights while VB.Net is kept out of sight like an ugly stepchild.

    • Jaroslav Mitrovic

      I agree with You. It was sad “We will do everything necessary to keep [VB] a first-class citizen of the .NET ecosystem”. Now it is obvious, it is at the end of the List. No “Code Cleanup for VB”? What? Why? I can´t imagine that all the MS-Office using Companies that made VBA Developers relevant, are now Old Stuff… I know the Launch of Visual Studio 2019 was about Young C#ers and not the Average Developer who learned Basic on old 8Bit Machines.  I am very flexible about languages in general and also Computer Languages, but I don´t want to use C# for a reason. I can use Visual Basic how it is, but I will need external Addons or Extensions, while a feature is left out for the Language that once was a “Citizen”. Now it is not “Cool” and I have a Hipster Beard, but do I need more Exclusion? Push my preferred Computing Language since 2006 to the Side and I get the impression somehow Python is now Pushed and the first-class citizen is now left behind. To be clear it is my Choice to use VB. But it is more and more obvious that the Numbers from “Stack overflow” are completely wrong as a Basis for Business decisions. If German Computer Science Professors use the C#-Language to teach .Net Programming, it was because the majority of them already are familiar with Java-Script and maybe PHP. The adaption in that filed was just a convenience for both Sides. And from there more and more beginner Questions are asked on that Webpage. That’s a biased View on Visual Basic. If the Statement that C# is used by Millions, and VB by thousands, why are thousands are excluded? With a hope for a Visual Basic reconsideration and with best wishes to all Developers, I leave here and by writing again a Wrapper for a C# thingy… thank You all for the patience and have a Nice Day.

      • Shawn Fumo

        Eh, honestly I find it very surprising that this could come as a shock. I mean C# and VB.NET were both first released in 2002, over 15 years ago. I’m sure they had more equal treatment at first, but it wasn’t for very long. For example a company I was with had converted the last part of their code over from VB.NET to C# back in 2010 because it was obvious even before then that things were moving more toward C#. And this was a large enterprise SAAS WebForms application in the financial space, not a startup company.
        Looking in the larger sphere of enterprise software, I’d argue C# is actually MORE average in the sense that it is closer to Java which still has some of the most code out there. Newer versions of C# may have more “hipster” features (like async/await) but the language itself is pretty well established for some time now. A lot of developers end up (unfortunately in my opinion!) eventually going into management. If I was thinking of an average experienced developer these days, I’d think it’d be pretty split between Java and C# on the business enterprise, PHP for the big CMS platforms, Java/Objective-C on phones, JavaScript on the web, C/C++ for low level and game engines and such, Python for science, and other things I’m missing.
        If we were to talk of newer/hipster stuff, it might be TypeScript on the web, Kotlin/Swift on phones, Scala, Clojure, etc. If Microsoft was somehow phasing out support for C# to concentrate on TypeScript, I’d understand that more. A more serious argument might be the big push to .NET Core lately on framework side (it’s pretty clear that .NET Framework itself will be in more of a holding pattern with the focus on Core going forward). But I’d be surprised by anyone starting a new project in VB.NET in the last 10 years or so unless they had a very good reason. Maybe I’m underestimating how many people still use VB.NET but I think you’re underestimating host many developers are out there using everything else. I have nothing against it (I even used VBScript with Classic ASP back in the day), but the writing has been on the wall a long time.

        • Terry Olsen

          I was a full-time VB.NET dev until several months ago.  We still have a lot of code in VB.NET that has to be maintained so I’m still in & out of it quite a bit.  But all new projects are built with C# by order of our new department head.  It was a lot easier to learn than I thought it would be.  I guess because I had already done a lot of work in JavaScript so I was familiar with the structure and just had to learn syntax.  Now when I have to go back to VB to fix something or change something, sometimes I can’t remember how I used to do it and have to look it up.  I’m losing my old-school cred!

  • Mark Adamson

    Note that stash doesn’t get backed up to the git remote which is where it differs from TFS shelve. If you want to back up some work, you might be better creating a separate branch for it, which could be on a fork or other remote if you don’t want to mess up the main repo with more branches

  • Mike Ward

    ShowClipboardHistory is `Ctrl+Shift+Ins`. `Ctrl+Shift+V` is much better. Good tip.

  • Mystery Man

    The GIF animation in the “C# Refactoring” section is very difficult to understand. I was forced to download it, convert it to an actual video (WebM) and watch it inside a media player so that I can pause, rewind and understand what’s going on in it.

  • Mike Diack

    Mads,Out of sheer frustration (and because us users of VS cannot reach him directly), can I ask you to contact John Montgomery:
    Please ask him to look at the number of existing regressions (yes, once working features in VS2017) in VS 2017 Update 8, that have NOT been fixed again as of 2017 Update 9.11.
    Users are now being directed by your tech support staff to install VS 2019 instead, this is just NOT good enough, particularly for users who cannot for tech/legal (e.g. compiler validation) reasons yet update to 2019. The product support staff are closing bugs as fixed, even though they aren’t!
    There is REAL frustration voiced at the VS feedback sites about the stuff broken by VS 2017 Update 8 and not yet fixed.
    See: “C++ console application with MFC/ATL doesn’t compile” (by Shawn Fox) as just ONE example, but there are many! Thats been open since Aug 2018Other bugs include an inability to use #import in C++ with the preprocessor(!)

  • Travis Illig

    The docs on Code Cleanup say that it will apply fixes from “current settings, .editorconfig, or Roslyn analyzers.” It appears to only handle current settings or .editorconfig at the moment. How can you configure it to run Roslyn analyzer fixes?

  • Jj maha

    I noticed that the code cleanup changes all variables to var instead of them being strongly typed
    There is a debate against and for var. My preference is to use strongly typed variables in c sharp
    Thru VS2019 is there a trend to move to var? 
    Curious to hear your thoughts. 

  • Jj maha

    I noticed that the code cleanup changes all variables to var instead of them being strongly typed
    There is a debate against and for var. My preference is to use strongly typed variables in c sharp
    Thru VS2019 is there a trend to move to var? 
    Curious to hear your thoughts. 

      • Jj maha

        Thank you for your prompt response. Am curious to hear your thoughts on the usage of var in a strongly typed language like C sharp

        • Dominik Andrzejczak

          It’s worth to note that var is still as strongly typed as explicit type declarations. There are many developers who prefers one or another, and I don’t think there is any consensus, but in my opinion var is much more popular and is also advised by pretty much every code refactoring tool I know.

          • Shawn Fumo

            Yeah, it is still strongly typed. The compiler already knows the type that is on the right side of the “=” and swaps out the “var” for that type as it compiles. Trying to re-assign the variable to another type later will still error out during compilation. Even some languages that are more strongly typed than C# (like Scala) have type inference shortcuts like this.
            To me, it just saves on visual noise. Usually it is pretty obvious what is going on, and hovering the cursor over it is enough to find out the type when I need to. This way it makes it easier for me to focus on the variable names, which should be the more descriptive thing anyway.