Visual Studio 2019 was released on April 2 of this year. With every release of Visual Studio (VS), Microsoft continues to provide new features to improve the productivity of developers. Even if you have already upgraded, you may not have taken advantage of the various new features yet. There are several great additions that can boost your productivity within VS 2019. These range from features that help you clean up and review code faster to live-sharing your workspace.
Code Cleanup and Fixers
VS 2019 has included refactoring and code styling capabilities for several versions, making it easy to apply collections of frequently used fixers to your code with a single click using the new Code Cleanup Profiles. The fixers include common actions like:
- Remove unnecessary usings
- Sort usings
- Remove unused variables
- And more
Running the Code Cleanup fixers can be accessed from the bottom toolbar of the document window.
The fixes can be managed using the Configure Code Cleanup dialog.
Clipboard History and Shortcut Key Mapping
Have you ever copied something only to then realize you needed to copy another line first?
Available on the Visual Studio Marketplace from independent devs for some time, VS 2019 adds Clipboard History as a built-in feature. It allows you to copy and paste several items. You can copy multiple code blocks and paste them whenever you need to.
This has been available on the Visual Studio Marketplace as an extension for some time, but VS 2019 adds Clipboard History as a native feature.
This is a great productivity feature as you’ll spend less time hunting down that piece of code you copied five CTRL-Vs ago. The default key mapping is CTRL+SHFT+INS, but not all keyboards have an Insert key, so one thing I do is remap this to something on my keyboard and that is more intuitive. I use CTRL+SHFT+V.
To change the mapping go to Tools > Options > Keyboard > Edit.ShowClipboardHistory. You can remap various other shortcuts from this menu. Click Assign to save the setting.
If you have ever used Visual Studio, then you are well aware of Intellisense, one of the key features that shows you the available properties and methods available when you put a period after an object.
IntelliCode takes this one step further as an AI-assisted coding feature that leverages thousands of open source projects on GitHub to automatically place the most likely code within a tailored completion list. This is just the first feature. There are many preview features both available and coming soon to utilize machine learning to improve your productivity. For more information see https://visualstudio.microsoft.com/services/intellicode/
Live Sharing is an exciting new feature that enables instant joint editing and debugging. It allows you to share your current Visual Studio project with a collaborator so you can work together in real time without cloning a repo or setting up a partner environment. Live Sharing includes shared servers like web apps and databases, voice communication, and a shared terminal. For more information on Live Sharing, see https://visualstudio.microsoft.com/services/live-share/
Git Improvements in VS 2019
In addition to the above features, Visual Studio 2019 includes some improvements to your Git workflow. I’ll dig into these more in a later post, but here is a quick explanation of the two that are most focused on productivity.
Git Pull Shortcut Key
Setting a shortcut keymapping for a Git Pull lets you update your repositories with just a couple of keystrokes. Under the Keyboard options in Tools, set the Team.Git.Pull command to use Ctrl+Shft+P to start taking advantage of the tip.
Git Pull Request Extension
Switching to the Azure DevOps web portal to manage pull requests is cumbersome. In VS 2019, you can use the Git Pull Request extension to create, review, and approve pull requests. Do so by installing the Pull Requests for Visual Studio 2019 extension at https://marketplace.visualstudio.com/items?itemName=VSIDEVersionControlMSFT.pr4vs
Microsoft continues to improve Visual Studio to make it a better coding environment. The 2019 release has been well worth the upgrade and the time spent exploring new additions. I hope these tips will help you keep your code fast and clean.