Little great things about Visual Studio 2019

Mads Kristensen

Mads

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!

Mads Kristensen
Mads Kristensen

Senior Program Manager, Visual Studio Extensibility

Follow Mads   

33 Comments
Avatar
Will Woo 2019-04-04 22:21:01
Confratulations, but, unfortunately, we're not off to a good start: https://www.codeproject.com/Messages/5616592/VS-2019-and-I-are-off-to-a-rocky-start.aspx
Avatar
Jens Samson 2019-04-04 23:38:20
Too bad, once again C# gets the spotlights while VB.Net is kept out of sight like an ugly stepchild.
Mark Adamson
Mark Adamson 2019-04-05 04:46:51
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
Mike Ward 2019-04-05 09:58:35
ShowClipboardHistory is `Ctrl+Shift+Ins`. `Ctrl+Shift+V` is much better. Good tip.
Avatar
"Fleet Command" 2019-04-05 22:27:19
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
Khizer Jalal 2019-04-06 10:04:57
This is Resharper version of visual studio 🙃
Avatar
Mike Diack 2019-04-08 01:56:16
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
Travis Illig 2019-04-08 10:55:54
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
Jj maha 2019-04-08 12:41:43
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
Jj maha 2019-04-08 12:42:04
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, 
Avatar
Niels Swimberghe 2019-04-08 14:40:20
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!
Avatar
Bernhard Danecker 2019-04-09 13:22:28
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 :)
Avatar
Tim Sørensen 2019-04-09 15:10:24
Congratulations on the release! VB.Net keeps getting better and better and the IDE feels a lot faster than VS2017.
Avatar
Matteo Contrini 2019-04-10 04:52:13
Is there an ETA for when VS 2019 is going to be available on Azure Dev Tools for Teaching (former Imagine/DreamSpark/MSDNAA)?
Avatar
Robin Wilson 2019-04-10 15:58:14
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.
Avatar
Sandro L. M. Barbosa 2019-04-10 21:16:02
Great Mr. Kristensen! Hail Visual Studio 2019!!
Avatar
John Cardinal 2019-04-12 09:03:03
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.
Avatar
Anil Kumar Pandey 2019-04-16 22:29:08
Very useful and productive options. Hope the list will grow more. 
Avatar
Stephen Przepiora 2019-04-18 06:42:00
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!
Avatar
Davide Lettieri 2019-04-19 07:41:27
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!