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

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!

33 comments

Discussion is closed. Login to edit/delete existing comments.

  • Jens Samson 0

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

    • Jaroslav Mitrovic 0

      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 0

        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 0

          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 0

    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

    • Niels Swimberghe 0

      Thanks for bringing that up. This is a good point.

  • Mike Ward 0

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

  • Mystery Man 0

    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.

  • Khizer Jalal 0

    This is Resharper version of visual studio 🙃

  • Mike Diack 0

    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 0

    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?

    • Mads KristensenMicrosoft employee 0

      At the moment, only current settings apply to Code Cleanup

  • Jj maha 0

    Hi, 
    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. 
    Thanks, 
    Jay

  • Jj maha 0

    Hi, 
    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. 
    Thanks, 

    • Mads KristensenMicrosoft employee 0

      You can change the preferences in Tools -> Options to match your coding style. Code Cleanup respect those settings

      • Jj maha 0

        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 0

          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 0

            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.

  • Niels Swimberghe 0

    Really happy to see we have stashing functionality inside of VS. This was the only feature that I was still using separate Git software for. Great work!

    • Kornelis Pieters 0

      It is usually easyer to use an extension for VS, that integrates well, than some complete separate software. So before deciding to do the latter, always attempt to find something here first.
      In this case, you would probably have found this here extension, that does a pretty good job of supporting git stash. Of course, if you’ve already migrated to VS 2019, you will not be needing it anymore. But for those that this is not yet an option for: give it a shot 🙂

      • Tsahi Asher 0

        +1 for that. I’m using GitStashExtension with VS2017 and i’m very happy with it.

  • Bernhard Danecker 0

    The new Code Cleanup feature is quite nice for it’s configurability. But it’s sad that it can not be combined with “Format Document”. In VS2017 there was an option to perform additional code cleanups when formatting documents. This option is no longer available. It would be really nice to see this again.
    My first approach of workaround by assigning the Code Cleanup to the Format Document shortcut wasn’t successful as Code Cleanup is not available in all editors like in razor views. I just want to have one shortcut which performs formatting + cleanup in all available document formats so I don’t have to think about it anymore. 
    I would be very glad if this regression could be fixed 🙂

  • Tim Sørensen 0

    Congratulations on the release!
    VB.Net keeps getting better and better and the IDE feels a lot faster than VS2017.

  • Matteo Contrini 0

    Is there an ETA for when VS 2019 is going to be available on Azure Dev Tools for Teaching (former Imagine/DreamSpark/MSDNAA)?

    • Mohamed Ali 0

      No one of them seems to know or care, one of them said he asked and they told him, in the next few weeks! Well, he said that few weeks ago! 

  • Robin Wilson 0

    It does seem a bit more responsive and has some nice new touches here and there.
    The part I can’t understand is why SSRS, SSAS and SSIS have to be seperate downloads and can’t be integrated with the main program and checkboxes in the installer as is the case with all other components. Trying to explain to IT depts how to install these seperate tools can be difficult. Before it was two downloads and now with VS 2019 it is 4. It’s like leaving out C# and telling people to have to go to some other website to download it. It is better that there is only one way to install these components rather than two with 2017 where one didn’t install all components properly.
    With VS 2017, updates to SSRS and SSAS often fail as conflict with each other so everything has to be uninstalled and reinstalled again (has happened with all PCs twice in the last 6 months) or SQL Data Tools fails to install and you must extract the VSIX packages and run each manually.
    Is there a valid reason these can’t be available from the installer? I think this would help avoid the reliability issues. Maybe also the illogical messages asking if you want to disable the reporting services plugin to improve performance when you are busy writing a report and would be unable to continue if you followed its advice.

  • Sandro L. M. Barbosa 0

    Great Mr. Kristensen! Hail Visual Studio 2019!!

  • John Cardinal 0

    One of the “Big not-great things about Visual Studio 2019” is the loss of the vertical document well. With that missing, VS2017 remains my preferred tool. The current MS position appears to be “we’ll think about it”, which is not promising. We know we need small, one-responsibility classes, and that means we have a lot of files, and we may have a lot of them open. Without the vertical document well, the doc tabs are a mess. I do not understand how the vertical document well is not a built-in feature, and was not an important-enough feature in the extension to ensure it was ported.

  • Anil Kumar Pandey 0

    Very useful and productive options. Hope the list will grow more. 

  • Stephen Przepiora 0

    I’m so glad you guys added Git Stash in, I had to drop development of my extension because we no longer used git and I just didnt have the time to keep a quick and dirty (but useful) extension working, kudos to you guys!

  • Davide Lettieri 0

    Changing the shortcut Ctrl+Shift+V to show the clipboard history is quite annoying I was faster with the old behavior. New features should have new shortcuts!

    • Mads KristensenMicrosoft employee 0

      The shortcut wasn’t changed. Ctrl+Shift+V has always cycled through the clipboard ring. The new thing is just that now you can visibly see what’s in the clipboard ring

Feedback usabilla icon