Hello, Let me start off by saying thanks for taking
the time to read through this post, and hopefully it won't waste too much of
your time (unless that was your plan
).
Anyway I'm Mark and I have been at EMC Consulting for just over a month now and
I thought it was about time I put up a post. So without further delay let's get
into the actual point of this post.
A couple of weeks ago I went to a conference called
Guathon. It was an event sponsored by Microsoft to tell developers about Visual
Studio 2010, ASP.net 4, MVC 2 and some
other technologies. Within the presentations that were given MVC 3 was
introduced along with the new razor view engine for ASP.net. Many improvements have
been made to MVC 3 to streamline the development process, with a very big
emphasis put on rebuilding and deploying code faster.
However, I digress as the post is called "Tips N Tricks"
and not "MVC 3 and the Razor view engine". As Visual Studio (VS) 2010 is being
adopted by more developers, it is important to know how we can utilise it effectively
to get the most out of the IDE. Although some of you reading this will probably
know some of the tips and tricks that can be done within the IDE not everyone
does and hopefully you will at least learn one thing from this.
A quick side note is that although ReSharper offers
most of this functionality but it is important to know that Visual Studio 2010
offers this out of the box and therefore allows you to get rid of clunky add-on's
and stops you from spending a fair bit of money.
WARNING: this post is biased towards using
VS 2010 with C# and C++ but I imagine the tips and tricks discussed should work
with the majority of environments.
IntelliSense
Within VS 2010 the IntelliSense search is performed
with a fuzzy search (meaning that possible relevant answers to your search
arguments are shown).
An example of this is if we wanted to find
HttpStyleUriParser typing
this out each time is quite mundane but with IntellisSense's fuzzy search typing
in just "h" shows a list of possible matches that we can scroll through to find the correct one.

However,
if we type "HSUP" (the first letter of each world within HttpStyleUriParser)
we generate a much shorter list to be able to select our desired object from.

The accuracy of the " HSUP" style search does differ
depending on whether or not you have other classes, methods or variables with
the same name styling. An example of this could be seen if you had one class
called HelpFunctions and another called HelloFoo, within this instance both option would be shown
within the drop down box of possible options whe you enter HF.

Box
Selection
I don't think box selection is the correct name for
this, however, due to the lack of a better name this is what I am calling it
.
This little feature is useful for when you need to
change something in bulk; for example we have declared 5 variables:

But we realise these should not be of type int they be
of type string, sure you can click on each one and rename them or you can
perform a box selection (I bet you never saw that coming
).
To perform a box selection you simple click just
before the first "i" on the first row you want to select (or click just after the
last "t" on the last row you want to select) and hold the mouse button down and
then you hold the alt key and simply drag the mouse down (or up) to select all the
properties you want to change. Once the selection has been made you can then just
start typing to replace "
int" with "
string".

(Another way to perform this action is by clicking
just before the first "i" on the first row you want to select and then holding
the Shift key and Alt key and clicking just after the last "t" on the last row you
want to select.)
Collapsing
and Expanding Methods
When classes get a little on the large size it can be
a pain to scroll through them to find the method you want. However, that need
not be a problem anymore with the help of ctrl+m+o and ctrl+m+l.
By pressing ctrl+m+o you can collapse all of the methods
that you have within your class so you can then browse through the class to
quickly find the method you want.

Then with the press of ctrol+m+l you can quickly expand
all of the methods again to see then in full detail.

Block
Comments
Block
Comments
If you have a large chunk of code that you want to
quickly comment out you have multiple options you can go through.
//int m_demo1;
//int m_demo2;
/* int m_demo1;
int
m_demo2;
*/
Or use a keyboard shortcut.
To use the keyboard shortcut you simply select the
block of code you want to comment out and then press ctrl+k+c.

To
uncomment the block of code you simply select the block of code and press ctrl+k+u.

Move between
open tabs
When you have multiple tabs open within VS 2010
it can me quite difficult to find the tab that you want, but by pressing
ctrl+tab
you can scroll through your open tabs and find your desired tab more
efficiently. Once you have pressed ctrl+tab a box similar to the one below is
shown.

By then hitting the tab key you will cycle through the
open tabs and the highlighted tab will change within the box. Once you release
the keys it will go back to the main IDE with the selected tab being shown. It is important to
note that you need to keep ctrl held or the box disappears, tapping the tab key will cycle
through the open tabs.
When this box is open you can also just click on the
file you want to show, instead of pressing the tab key to cycle through
them.
Auto
complete of statements
For each type of statement that can be generated (such
as for, foreach, while, try catch, if etc) visual studio 2010 lets you auto
create templates of them with dummy information filled in ready for you to
change.
For example a foreach statement would look
like the image below.

As you can see there are three sections that you can
change; the type of the object, the name you want to give each item that is
pulled from the collection and the collection to loop through.
- To create a template
statement you type the statement name you want and then hit the tab key twice.
- The first section
to change is the data type that the item should be. Once you have typed that in
you then hit the tab key (when you hit the tab key it moves over to the next editable parameter).
- The next section
to change is the name you want to give the item. Once you have typed that in
you then hit the tab key again.
- Finally the last
section is the collection you want to use. Once you have typed that in you hit
the enter key and your foreach statement is ready to use.

Incremental
Search
Incremental search allows you to perform a quick
search within the currently selected class you have open.
To use it all you do is press ctrl+i and then start typing, as
you type results matching your search text are highlighted within the editing
area. Note that what you are typing appears in the
bottom left of the windows in the status bar area and not in any form of popup
window.
To exit incremental search you just hit the escape key (or click
the left mouse button inside the editing area).
View Call
Hierarchy
Sometimes you want to know where a specific method
within a class is being called. You could do this by putting a break point
within the method in question and then tracing your program through to see where
the code returns to. However an easier option is to use the call hierarchy.
Within the call hierarchy calls to your selected
method and calls from your selected method are shown. This allows you to
quickly jump to the sections of your code where your selected method is being
called from.
To view the call hierarchy of a method simple select the
method you want to view and press ctrl+k+t alternatively
you can right click on your selection and select "View Call Hierarchy". Once
you have done this the call hierarchy will be shown and look something like
this

By double clicking on RandomFunction() you would be
take to the method called RandomFunction().
That is all you're getting from me for now, as there
are so many little tips and tricks books could be written on them (besides I think I have wasted
enough of your time).
Thanks for reading the post and hopefully you did
learn something new.