Visual Studio 2017 Productivity Tips

Introduction

In this write-up, we will discuss developers' productivity tips in Visual Studio 2017. We’ll discuss some cool tips and tricks that can save our time throughout the development. Basically, the purpose of this article is to boost up your skills in Visual Studio 2017 so you can do more in less time. After reading these tips, if you can save 5 minutes in a day, then imagine the number of hours you will be saving per year. So, reading this article is not a bad deal. Now, if you are motivated enough, then let’s check if you are eligible for reading this.

Background

Before you start reading ahead, you must have basic understanding of how to work with Visual Studio as a tool, no matter which version you are using -  2008 or higher.

Enough introduction! Let’s learn something.

#1 - Close all documents at once

Whenever we are working on a project, we open multiple types of documents to write code. Working after a while, we realize that it’s too rush here, let’s clean some space to open new files to work with. To close all the documents, normally you right click on focused document’s header and choose close all documents option.

Visual Studio

But, if you are a ninja developer, you soon realize that using mouse is time consuming. You don't use mouse but instead, you would like to use keyboard shortcuts, that is a quicker way to do things. Here is the tip for closing all documents.
Visual Studio
By pressing (Ctrl+Alt+W), you can close all the documents at once. If that shortcut is not working in your Visual Studio, then no worries; you can create the same with few clicks. We will discuss this in the following section.

#2 - Creating Your Own Keyboard Shortcuts

Keyboard shortcuts are very useful and can save much of your time. If you are not having a particular shortcut in default VS settings, then you can create your own keyboard shortcuts for hundreds of different commands, and it's extremely easy. To assign a shortcut to a command,

  1. Select Tools->Options from top menu.

    Visual Studio

  2. Now, select ‘Keyboard’ under ‘Environment’ from left.

    Visual Studio

  3. Now, you can set keyboard shortcuts for any available commands by typing its name in "Show commands containing"  text box, and selecting the command from below result list.

    In our case, we need to define a shortcut for CloseAllDocuments command.

    Visual Studio

    If you don’t know the exact keyword for command, then type something related and scroll down manually to find the exact command.

  1. After selecting the command, Visual Studio will show you the associated shortcut to that command if any.

    Visual Studio

    Otherwise that option will be disabled.
  1. Now, you can assign a new shortcut to the selected command from the very next menu by focusing on shortcut keys: text box and pressing the keyboard keys in same order, we want them to hit the command. In our case, we will press (Ctrl+Alt+W) after focusing on text box and finally press the assign button.

    Visual Studio

#3 - Save changes to multiple documents at once

As we write and modify code in multiple files, there are chances that we may have multiple files with unsaved changes.

Visual Studio

Manually saving changings to each individual file by pressing (Ctrl+S) is really tedious and time consuming. By using a keyboard shortcut, we can save changes to all unsaved documents at once. Here is the tip for it.
Visual Studio
By pressing (Ctrl+Shift+S), you can save changes to all documents at once. This keyboard shortcut is available in Visual Studio 2017’s default settings on my computer but if it’s not available on your device, now you know how to create one for you.

#4 - Add New Item

Adding new items is something that we do very often.

Visual Studio

Remembering a keyboard shortcut for that is a great deal and can save a lot of time. Here is the tip for that.
Visual Studio
By pressing (Shift+Alt+C), you can open "Add New Item" menu.

#5 - Quick action and refactoring

Quick action and refactoring is a feature in Visual Studio that can keep you moving forward whenever you get a problem, a warning, or you want to refactor your code.

Visual Studio

Quick action and refactoring is called code forwarding technique in ReShaper terms. ReShaper is a great code refactoring tool from JetBrains built for Visual Studio. It’s is a master piece in code refactoring and wide intelliSense; and believe me, I’m not getting a penny from JetBrains. I’m telling you because I want you to be more productive and that’s what the purpose of this writing.

Now, back to quick action and refactoring, and here is the tip for it,
Visual Studio
Press (Ctrl+.) if you want Visual Studio to be a good friend and sort out a possible solution for you.

#6 - Vertically Typing

To perform vertical typing on multiple lines simultaneously is useful when you have to write same thing at more than one places.

Visual Studio

Here is how you can do that.
Visual Studio
Hold (Shift+Alt) and press the down or up arrow button to select in which direction you want and keep pressing as much as you want.

#7 - Delete all Break Points

Debugging without break points is impossible and no one can write a perfect piece of code. So, we need debugging and for that, we need breakpoints. During debugging, we set multiple break points at multiple places to inspect our code. Here is the tip to delete all breakpoints after you fixed something.
Visual Studio
Press (Ctrl+Shift+F9) to delete all break points in one go.

#8 - Format code in documents

A good formation of code helps to understand code easily. In Visual Studio, it’s easy to format code in a file and here is the tip for it.
Visual Studio
By pressing (Ctrl+K, Ctrl+D), you can format code in a document.

Visual Studio

#9 - Cut and delete a Line

Cutting a line and copying it to clipboard or deleting it altogether is something in Visual Studio that I personally found very useful at times.

Visual Studio

Sometimes, we need to cut the line and paste it somewhere else or delete it altogether. Here is the tip for doing that with two and three keyboard clicks instead of using mouse which is time consuming.

Visual Studio

To cut a line and copy it, press (Ctrl+L) and to delete it without copying it, press (Ctrl+Shift+L). If these shortcuts are not available in your installation, then you can create both of them by following [Creating Your Own Keyboard Shortcuts] section of this article.

#10 - Remove Unnecessary Namespaces

To remove unnecessary namespaces, press (Ctrl+R,Ctrl+G), or create your own shortcut if required.

Visual Studio

After pressing (Ctrl+R,Ctrl+G)

Visual Studio

That's it. I hope, you will find this article helpful while programming on Visual Studio 2017.


Similar Articles