LIVING WIKI: This means that this blog post will get updated frequently with more content.
These are tips strictly focused on those of you working with large projects – either tons of lines of code in a single file, having many, many files, or having a complex folder hierarchy. They should not be used gratuitously, as they may slow down performance or unnecessarily clutter a small project. However, when it comes to large and complex solutions, these tips are invaluable.
Tip 10a. Keep track of where you file-wise are in a large project.
For more tips like this, LIVE and IN PERSON, come see us at the MSDN Roadshow !
If you have ever worked with large project files, sometimes you lose track of which file you are in. You could look at the tab name to see which file you are in, but what if you want to know how deeply nested that file is inside the solution? This is where it’s handy to track your location within the Solution Explorer, with a subtle highlight indicating your location. The default behavior is that the item you last opened will remain highlighted and the Solution Explorer will not refresh as you move about your project files. You can change that highlight to be dynamically synchronized to your current file location.
It’s easy to turn this feature on – just go to options and under Projects and Solutions, you will see checkbox: Track Active Item in Solution Explorer. By default it is unchecked to keep the IDE performance snappy. Once you check it and hit ok, you’ll be able to track your location in the Solution Explorer.
Remember, once you customize your IDE the way you like it, be sure to Export the Settings out so you can import them onto a new or rebuilt machine.
Tip 10b. Do you have a very verbose and long method?
If you have a very length method that’s difficult to navigate, there are two tips that you’ll find handy – both new to Visual Studio 2010.
The first tip takes advantage of the new WPF-based Visual Studio IDE. As typical with any WPF project, you have the ability to do vector based sizing – this means that everything is zoomable! You can use the mouse scroll keys to zoom in and out of your project code seeing more or less lines of code as you wish.
Th second tip is not as obvious. This actually is a bug fix of sorts. In previous versions of Visual Studio, when you had really long methods, oftentimes you would use #region and #endregion statements to create collapsible chunks of code. However these tags end up adding clutter to your code, making it less clean looking. The other choice you had in Visual Studio 2008 was to turn off automatically Document Outlining, and right click chunks of code with the “Hide Selection” option. This would eliminate the messy #region/#endregion statements; however, once you turned Document Outlining back on, all your selections would be erased.
This is no longer the case in Visual Studio 2010. Now you can create region-less collapsible chunks of code along with automatically document outlining. Just right click and select Hide Selection to create the region.
Another new feature is an active region bar. On the left hand side of the code editor, if you hover your mouse above the line between the + signs, Visual Studio will automatically highlight the relevant lines of code for that region.
Tip 10c. Do you have a ton of methods, properties and events?
Visual Studio 2010 introduces a new feature called Navigate To. This one is definitely one of my favorites. Instead of having to remember where I put a method, I can use fast intelligent searching with the quick pick functionality, zipping right to a method anywhere in any file in any project!
It’s really easy to trigger this function. Just hit CTRL+, (comma). This will pop up the Navigate To dialog box. Once it’s up, you can just type in the first letters of the method and the quick pick will filter out matches for you. You can even search for multiple words by separating each word with a space. Then, all you have to do is double click on the method you wish to view, and Visual Studio will automatically zip you directly to that method. It’s fast! Try it.