OK, so this is another round of tips on using Visual Studio! See first collection here, second here and third here.
Create shortcuts: you can create shortcuts to frequently used code. Just click <Ctrl>-K-H on any line, and you will add a shortcut to it:
After that, you can jump to any of your bookmarks from the Task view:
To remove it, click <Ctrl>
again in the same line. Note that this is not
the same as the bookmarks featured introduced in the third set of tips
Code Maps: this requires Visual Studio Enterprise. Open the Architecture menu and select Generate Code Map for Solution.
You will get a nice diagram showing all dependencies between assemblies in your project:
Code Metrics: get a static analysis report of your project, only in Enterprise edition. In the Solution Explorer, right click on your project, Analyze, and select Calculate Code Metrics.
Format document on save & remove unused and sort using statements on save: Visual Studio can take care of formatting your documents and removing any unnecessary using
declarations for you, when you save your documents; you just need to install the Productivity Power Tools
extension and enable these options in Tools
– Productivity Power Tools
Thread Deadlocks: Visual Studio can show you thread deadlocks while debugging. When debugging a multithreaded app, break it and open Debug
From here, you can flag your code so that it is more clearly visible.
Executing code in Immediate Window: the Immediate Window can be used to run .NET code. While debugging your app, pause it, and select Debug – Windows – Immediate:
You can enter any .NET expressions and variables or even complex expressions and see them evaluated at once.
- Pin and export Data Tips: while debugging, break and hover any variable or field in your code. Click the pin icon on the right of the tooltip window. This will create a Data Tip.
You can have multiple Data Tips, add comments to them:
Also save Data Tips to files so that they can be loaded in another Visual Studio session, and, of course, load a collection of Data Tips:
Place reusable code in Toolbox: you can add code that you use frequently to the Toolbox. Pin your Toolbox window, highlight your code and drag it to the Toolbox. Even if you are not working in a visual app, the code snippet can be dragged from the Toolbox into your code:
Change C# language version: Visual Studio can use any of the C# versions. For example you may or may not want to use the latest (and greatest, by the way!) features of C# 6. All you have to do is right click on a project, Properties
. In the Advanced Build Settings
window, Language Version
, select the one you want to support:
- Find tips: some tips related to the Find functionality. First, you have two results windows, 1 and 2, and you can have your search results appear in any of them:
With this, you can also append to current results or show only the file names that match the search pattern.