October 17, 2007

Current favorite ReSharper shortcuts

I've been experimenting with ReSharper shortcuts again. Here are my new favorites.

Ctrl-- (control-minus): return cursor to previous position.
This is especially useful if you just had ReSharper create a field or do any number of other items that will automatically jump the cursor to some other place -- be it in the current class, or another file. Very useful. I seem to use this most when I'm creating properties.

Ctrl-Alt-V: Introduce Variable.
If I type:
System.IO.File.ReadAllLines(filename);

Then hit the Ctrl-Alt-V, it will create a variable for the return of the function. So you will end up with this:
string[] lines = System.IO.File.ReadAllLines(filename);

Ctrl-Shift-N: Find file by name
I'm used to using Ctrl-N, find type by name. But usually what I was looking for was find file by name. If your classes have the same names as your files, not a big difference, but there is a difference.

What I'm hoping for in the next version of ReSharper
Enhanced Interface support. If my class has an interface, I want to be able to right-click on a method that is not in the interface, and have ReSharper automatically add the method to the interface.

Update:
From my comments I see that this feature already exists, it just has an odd name and no short-cut. The feature is "Push member up".

So put your cursor on a method/property, right-click->Refactor->Push Member Up and you will get a dialog for adding the member to an interface.

The name is the odd part, but if you do think about all the implications, it does make sense. Anyway, the more you know... Thank you Ilya Ryzhenkov

2 comments:

Ilya Ryzhenkov said...

You can use Push Members Up refactoring to move methods from implementing types up to interface.

Chris Brandsma said...

Thank you for the info, I updated the post with that info.

I just wish it was on the Refactor short-cut (Ctrl-Shift-R )(there is probably a way to do that as well)