#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.
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.
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,
- Select Tools->Options from top menu.
- Now, select ‘Keyboard’ under ‘Environment’ from left.
- 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.
If you don’t know the exact keyword for command, then type something related and scroll down manually to find the exact command.
- After selecting the command, Visual Studio will show you the associated shortcut to that command if any.
Otherwise that option will be disabled.
- 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.
#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.
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.
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.
Remembering a keyboard shortcut for that is a great deal and can save a lot of time. Here is the tip for that.
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.
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,
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.
Here is how you can do that.
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.
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.
By pressing (Ctrl+K, Ctrl+D), you can format code in a document.
#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.
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.
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.
After pressing (Ctrl+R,Ctrl+G)