RSS
Facebook
Twitter

Friday, May 08, 2009

15 Resharper keyboard shortcuts you need to know

image

I use Resharper daily and it help me to write better code faster. The only downside is that the developer needs to learn many keyboard shortcuts in order to properly use its functionality.
While I'm still learning new shortcuts every day I've found that I keep using several shortcuts most of the time.
The list below is an incomplete list of the keyboard shortcuts I've found useful in no particular order:

  1. Ctrl+Shift+Space - Smart code completion
    The ace of the pack, since I've started using it I do not need to write trivial code anymore.
    Using this shortcut tell Resharper to fill the obvious code: it can write the method's arguments in a method call, finish the initialization of a method and more.
  2. Alt+Enter - Show available quick fixes and context actions
    When there's an error in the code or Resharper has suggestion on how to improve a certain line it marks it with a red, yellow or blue underline, using this shortcut will open a context menu with the suggestions on how to repair, improve or change the code. Need to change the accessibility of you method from private to internal? want to change a delegate to lambda? this shortcut is your one (two) click solution for these problems.
  3. Ctrl+ L Mouse - Go to declaration
    I use this shortcut a lot. Clicking a method call, variable or type while holding the control key will take you to the definition of the clicked object. It's easy to find where an object was declared and find it's implementation.
  4. Ctrl+W and Ctrl+Shift+W- Extend/Shrink selection
    a class, method or for loop it's amazing how many times I need to copy or cut a certain scope. this shortcut tells Resharper to select the current scope, pressing it again will select the overall scope and so on. for example if the cursor is inside an if call the first (sometime second) selection will select the entire if, the next will select the method and the last will select the whole class.
  5. Alt+Insert - Generate code
    Depending on the cursor location using this keyboard shortcut will create a piece of needed code.
    When used in a class context it can create properties, constructor (along with variables initialization), implement or override members.
    When called inside the solution explorer it can create a new file from a predefined template.
  6. F2 - Rename this
    This rename is smarter and more powerful version of the simple quick rename visual studio has. It renames the method, variable or class along with all of the places its been used and it even renames related comments.
  7. Ctrl+Shift + R - Refactor this
    Opens a context menu with all of the refactor options available according the where the cursor is. Extract to method, introduce variable and more. Although each refactor option has its own shortcut it's easier for me to learn just this one and choose the refactor I want from the context menu.
  8. Ctrl+F6 - Change signature
    Ever needed to add or remove a method call parameter? what about changing the order of the parameters after the method has been written and being called from somewhere else in your code?
    Using this key shortcut you can add, remove or move the method parameters. Resharper automatically adds the needed code on the method calls as well where possible.
  9. Alt+F7 and Alt+Shift+F7- Find/Goto usages
    Need to find where a method or class is used in the code? just use this simple shortcuts and either get a list or just go to the caller.
  10. Ctrl + Alt + B - Goto inheritor
    When I need to go to the classes that inherit (or implement) another class or interface I use this shortcut to quickly jump to them. 
  11. Ctrl + E - Goto previously opened file
    Most of the time when I work on fixing bugs or implementing a new feature I keep jumping between a small subset of the project's files. This handy shortcut opens a searchable list of all of the last files opened sorted according to the last updated file. When choosing a file from the list it opens in the last place I've been when I've worked on it.
  12. Ctrl + N - Goto class
    I use this shortcut to open classes without going thought the solution explorer. Using it is simple start writing the class name and choose the one you need from the list. It can even handle wild cards (*handler).
  13. Alt+Shift+L - Locate in solution explorer
    From time to time I need to find the actual file I'm working on in the solution explorer. If you didn't set the auto follow option in visual studio (like me) this shortcut is a real time saver. instead of searching for the file in a big project structure just use control and L.
  14. Ctrl + J - Surround with template
    Ever finished writing a block of code and decided it should be inside a try..catch block? using Ctrl+W (see above) you can select that code and using this shortcut you can automatically surround it with one of the template provided including try..catch, for, if and so on.
  15. Ctrl + Q - Quick documentation
    Gives you a very quick, but thorough overview of the method or variable that you have your cursor on.
    You can even use it to check you own XML documentation while working on it.

 

I know there are many more useful shortcuts - if you know one feel free to write a comment about it.

3 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...