ReSharper Help and Tutorial

I have found that for me, ReSharper wasn't even close to as great a help until I changed my operating basis regarding how I write code. Many times there are many subtle things you do differently, which just causes pain with ReSharper. It also wasn't easy for me to find and remember all the key combinations. To this day when I can't remember, I just open the Tips it gives during start up and just cycle through them until I find the one I am looking for. (Definately not expeditious since they have a cool PDF reference card now).

So I thought I would write up a quick tutorial on the functions I use most and give some help to those that may not of discovered them or found them not to be as useful.

Optimize Usings

Before:

It highlights in gray any using's that aren't being used.

After:

I love de-cluttering and absolutely hate how I find other peoples code declarations (especially in ASP.NET after the designer adds a bunch of stuff you don't reference in the code behind).

Surround With

This is the problem that had me shaking me head. When I code, a lot of time I don't know I need a particular statement until after I write the line of code. It would cause me so much lost time deleting and moving code around. So if I have:

x = 29;

and then I realize I need an “if” surrounding my statement, I would start typing the “if” and as soon as I hit the enter key after the line, it would insert the {} after my “if”, but BEFORE my code, like:

if (x == 0)
{}
x = 29;

What I really wanted it to do was:

if (x == 0)
{
x = 29;
}

This is where the “Surround With” feature comes in. Highlight your code (in my case x = 29;), Hit Ctrl+Alt+J, and choose “if”. You get:

if ()
{
x = 29;
}

and then it puts the cursor between the paranthesis to do your “x == 0” check.

And of course, you can also define your own “Surround with” macros. I made a few no brainer ones for conversions:

All I do is highlight the “29”, hit Ctrl-Alt-J, hit the “A” key and:

x = Convert.ToInt32(29);

5 thoughts on “ReSharper Help and Tutorial”

  1. Nice post Scott. I didn’t know about the Method Navigation or “Mid-Function” Intellisense – both sound very useful.

    I’m looking forward to part 2.

  2. Thanks Tim, I appreciate it. I didn’t get a lot of sleep on Thurs night, and decided to spend what brain cells I had awake on some posts like this one.

  3. Have you ever done CTRL-SHIFT-space bar in a parameter list in VS .NET ??? (without this resharper)

    Magic will happen

    So that CTRL-P will not make me use this darn resharper. I find it much too agressive. Sometimes I change a small piece of code like a bracket or so and all of the sudden my whole file is filled with 100 red warnings .. That doesn’t help you to find the one bracket that is missing no ?

  4. I’m author of popup editor and help system – GhostClip (www.ghostclip.com) . It can display an image or text ghosted over Visual Studio. This is really good for learning keyboard short cuts for programs like Resharper or just for programming aide.

  5. Thanks Scott! This was a short but very well illustrated & exemplified post. My attention had gone (naturally I guess :-/ ) to the comments below it and since your comments about shortcuts were fresh, I thought I’ll check one of the links in the 4th comment: GhostClip (www.ghostclip.com).
    What I realised is that, the above link is no longer valid, as I got the an error about the concerned account being suspended, just FYI.

Leave a Reply

Your email address will not be published. Required fields are marked *