Today I’d like to show you a few shortcuts I frequently use from ReSharper and the equivalent functionality in Visual Studio for when ReSharper isn’t available.
ReSharper shortcuts and Visual Studio equivalents
Keys separated by a ‘+’ symbol indicate that keys are pressed at the same time, otherwise they are pressed separately.
The reason I’ve noted the Visual Studio equivalents is because quite often I find myself assisting other developers or writing code at someone’s desk other than my own. If you can navigate the IDE quickly no matter where you are then you’re looking at time savings over the lifetime of your career.
Locating an item in Solution Explorer
To bring up Solution Explorer and bring it in to focus press Ctrl+Alt+L. This won’t highlight the item currently being edited though. There are times this might be desirable.
Use ReSharper to open Solution Explorer and also highlight the file you’re editing by pressing Shift+Alt+L
Visual Studio 2012 and later has this functionality but you’ll need to create a shortcut. In the screenshot below I’ve mapped it to the same keyboard shortcut as ReSharper.
Go to file/type/symbol
Find files, folders, types and symbols such as methods and properties using ReSharper’s “Go to everything”. The shortcut is Ctrl+T.
You can also go to a specific line number in a class or file by putting in the number after the search string. It will also give you the snippet of code on that line!
Visual Studio since version 2010 introduced a feature called “Navigate to” which offers similar functionality. It searches file, folders, types as well as symbols. The shortcut for this is Ctrl+,
Extract code into a method
Highlighting a block of code and extracting it into a method can be done in ReSharper by pressing Ctrl+R+M.
A similar function in Visual Studio can be found in Edit > Refactor > Extract Method
Obviously not as sophisticated, but it will get you by with sensible defaults such as private accessibility.
Find all references
There are a couple of ways to find references with ReSharper. The first is a nice inline menu which is nice when there aren’t many possibilities.
You’ll get this context menu by placing the cursor on a member or type and pressing Shift+ALT+F12.
You can get a more verbose listing by pressing Shift+F12, which will actually show a small snippet of code where it’s used as well as it’s position in the hierarchy of the solution.
Visual Studio has a similar function called “Find all references” which can be activated by placing the cursor on a member or type and pressing Shift+F12. Again, not as sophisticated but good enough.
View call hierarchy
ReSharper gives you the ability to see incoming and outgoing calls to a method. Extremely useful if your trying to get an idea of the call stack.
Although there’s no default shortcut for this in ReSharper, there is for Visual Studio. It’s Ctrl+K Ctrl+T.
The ReSharper version of the call stack offers a few more functions such as exporting to XML, Text or HTML and also has a code preview. You can find it at ReSharper > Inspect > Outgoing/Incoming calls and bind a shortcut.
Go to implementation
In standard Visual Studio, when you press F12 on an interface member it takes you to the interface definition. Most of the time this isn’t what you’re after, you want to see an concrete implementation.
One of my favorite features in ReSharper is the ability to go to an interface implementation by pressing Alt+End
If there are multiple implementation, it will give you a list to choose from and also let you filter as you start typing.
Apart from the nice UI provided by ReSharper, Visual Studio 2015 Update 1 now has the same functionality. You can get to it by right clicking on the interface and selecting “Go To Implementation”. On one of my machines where I don’t have ReSharper installed, I’ve mapped it to the same keyboard shortcut.
Which then displays Visual Studio’s implementation listing.
There’s quite a few developers out there who don’t like ReSharper. It doesn’t really matter which side of the fence you’re on but I think it’s important to be flexible with the different environments and configurations you may come across.