Here I have listed 15 easy tips in Visual Studio 2019 which will reduce your development time and increase the productivity.
- Code Cleanup
- Solution Load Time
- Search in Watch Window
- Track active file inside Solution Explorer
- Cycle Clipboard Ring
- Remove and Sort – Namespaces
- Track of Miscellaneous files
- Run to cursor
- Reusable code into Toolbox
- Show the output window automatically
- Run the web application in multiple browser
- VS Quick launch
- VS shortcuts
- Vertical selection
- Collapse all
Note: I have shared the same article with Syncfusion Blog, and also I’m sharing same here which helpful to my subscribers.
Visual Studio 2019 provides on-demand formatting of a code file, including code style preferences, through the Code Cleanup feature. To run Code Cleanup, click the broom icon at the bottom of the editor or press CTRL+K, CTRL+E.
Solution Load Time
You can improve the performance of project/solution, Navigate to Options -> Project and Solutions and disable this option “Restore Solution Explorer project hierarchy state on solution load”.
Search in Watch window
The Watch window provides an advanced way to examine a variable. To watch a variable while debugging, add it to the Watch window by right-clicking the variable or the DataTip and selecting Add Watch. The variable will appear in the Watch window. In Visual Studio 2019, we can see search feature inside the watch window. Using this search, you can quickly identify the properties.
Also, you can find all the possible format specifiers by double clicking on the property row, then type “,” after the property name. Refer below picture.
Track active file inside Solution Explorer
This option will reduce your development time when you work with large projects, when you work with project which has large number of files, you always found difficulties to find out the current active file in solution explorer, you have the scroll through the entire solution explore to find this. To find out this current active file in editor inside the solution explorer, you just select the option “Sync with Active Document”, refer the option shown in below picture,
How to Track it Automatically?
You can track the active file automatically by enabling the below option,
Navigate to Tools -> Options -> Projects and Solutions -> General ->” Track Active Item in Solution Explorer” then check the option to turn on this feature automatically.
Cycle Clipboard Ring
Edit -> Cycle Clipboard Ring or CTRL + SHIFT + V will be used to perform multi-paste action.
When you press Ctrl + C (copy action) or Ctrl + X (cut action) in Visual Studio to Copy or Cut a text content or code block, the Visual Studio keeps the last 15 copied/cut content in memory. Cycle Clipboard Ring allows you to cycle through your Clipboard and paste the right code block.
Example: You just copy/cut some text continuously some 10 count, then paste any one of copied text using CTRL + SHIFT + V, keep pressing these combinations change to paste content until you found the desired content to paste.
Remove and Sort – Namespaces
It is important to keep the coding standards in our development, most of the time we missed to maintain this code standards like using unused namespaces, namespaces arranged in proper sorting order, use the system directives at top. Visual Studio has option to organize these easily.
In Code editor, right click to show the context menu, where you find the option “Remove and Sort Usings”. Click on this option will remove the unwanted namespaces and sort the namespaces in ascending.
But you face another type of code standard issue which say, ‘System Directives should be place first’. Keeping the System namespaces first has been the one of the best code practices. This could be overcome by setting the below option.
Navigate to Tools -> Options -> Text Editor -> C# -> Advance -> “Place ‘System’ directives first when sorting usings“ then check the option to turn on this.
Track of Miscellaneous files
Some time we need to group some external files which is not inside the project folder or source or added to solution file, these external files can be used for our references in development stage. So Visual Studio has option to group these files under the Miscellaneous folder. External files which opened thorough Visual Studio code editor have been grouped under this Miscellaneous Folder, you can see this folder in solution explorer.
By default, this option is disabled. To enable this, navigate to Tools –> Options –> Environment –> Documents and then select “Show Miscellaneous files in Solution Explorer”
You can set the files count also, here we set count as 5. So, 5 external files have been listed under the Miscellaneous folder.
Run to Cursor
Run to cursor can be used while debugging the code efficiently, this will reduce your debugging time by directly stop the debugger to where you pointed your cursor. Using this way, you can avoid step by step debugging until this reach the point where you really want to start the debugging. When you select the run to cursor option, visual studio starts the debugger automatically and execution stopped to the selected line.
In code editor, right click on the line where you want to stop the debugger, you will see the “Run to Cursor” option from the context menu; Select the option. Refer below picture,
You can also use the shortcut key “CTRL + F10” to do this.
Reusable code into Toolbox
Visual Studio having a great feature, that you can place your code snippet inside the toolbox. For that you need to just select the code snippet and drag the selected snippet on to the general Tab.
This feature will be more useful, when you need to use some code in multiple files or places. You do this usually copay the codes from page you already have that code, and then paste that code to new page or place. We lose our time to scroll and find out the files or pages to copy and paste this common code snippets.
Visual Studio provides space in Toolbox where you can keep the common code, from the toolbox you can just drag and drop where ever you want to paste the code snippet.
To keep your common code to Toolbox, just open the Toolbox -> Expand to General Tab, where you just drag and drop the selected code blocks. Refer the below picture, here I have selected 3 lines of code, and drag and drop to General Tab area.
You can also rename it for easy references. Below I have renamed the above code block to “TestMethod”. You can just drag and drop the “TestMethod” from Toolboxto any pages or places to reuse the same codes.
Show the Output Window Automatically
You have option in Visual Studio to set the output window to be opened automatically when you start the build each time.
Navigate to Tools > Options > Project and Solutions, then Select “Show Output window when build starts”.
Run Web Application in Multiple Browser
Usually we run the application in any one browser and ensure the pages. But as a web developer we need to ensure the applications in all major browsers. Running the application in Visual studio have option to run it in multiple browsers simultaneously. To do this,
You can select the “Browse With…” option in the browser list drop-down, below dialog will open, and you can see all the list of browsers along with the browser which marked as “(Default)”. Here, you can select all the browser in which you want to run the application together and click on “Set as Default”. Now if you click on “Browse” button in the same dialog control, you will find your web application starts on all the selected browser simultaneously.
VS Quick Launch/Navigation and Search
You can navigate to any file, class, type, member or symbol declaration quickly using the Go To option in Visual Studio. To open the Go To window, press CTRL+T or CTRL + , or click Edit > Go To. Go to All enables you to jump to any file, type, member, or symbol declaration quickly.
You can reduce development time by the way of finding the required files. You can use the Visual Studio search files option effectively to reduce the unwanted manual look ups.
Search inside the current file – Ctrl + F
Search inside the current project – Ctrl + Shift + F
Use VS shortcuts
Visual Studio keyboard shortcuts are the key thing to work more efficiently and speeding up your development work. You can find more useful visual studio shortcuts in this link.
Some of the common shorts
|Ctrl-X||Cut the selected item to the clipboard.|
|Ctrl-C||Copy the selected item to the clipboard.|
|Ctrl-V||Pastes the item in the clipboard|
|Ctrl-Z||Undo previous action.|
|Ctrl-Y||Redo the previous undo action.|
|Ctrl-S||Saves the selected file.|
|Esc||Closes opened menu/dialog.|
If you need to select multiple lines vertically, you can do that by placing the cursor on the first line of start point, holding Alt, and dragging down.
Use Ctrl + M and O to collapse all your code.
You can refer the below article which has some basic tips to use Visual Studio for the junior developer.