mo.notono.us

Tuesday, June 15, 2004

ReSharper Tips

I guess this was the Secret Feature that the JetBrains guys hinted at in version 84: The beginning of some documentation for ReSharper. There are quite a few features here that I was not aware of:
  • Using Alt+Insert (ReSharper > Code > Generate...) in the editor, you may easily generate a constructor, a property for any field of your class, implement interface members or override members from base classes.
  • You may quickly find all places where a particular class, method or variable is used in the whole solution by positioning the caret at the symbol's name in the declaration or at its usage in the code and pressing Alt+F7 (ReSharper > Search > Find Usages).
  • When you use "Find Usages" action and browse its results, you may use Ctrl+Alt+Up and Ctrl+Alt+Down shortcuts to navigate between found occurences. You may invoke them directly from the editor without need to switch to the find results.
  • To open any file in the solution quickly, press Ctrl+Shift+N (ReSharper > Go To > File...) and start typing the name of the file (wildcard characters allowed). Choose the file from a drop-down list that appears.
  • To navigate to the implementation(s) of an abstract method, position the caret at its usage or its name in the declaration and press Ctrl+Alt+B (ReSharper > Go To > Inheritor). Using this shortcut you may also navigate to implementations of an interface, inheritors of a class, overriding methods of a virtual method, etc.
  • When you use "Highlight Usages" action (Ctrl+Shift+F7), you may use Ctrl+Alt+Up and Ctrl+Alt+Down shortcuts to navigate between highlighted occurences.
  • To uncomment code commented out with a block comment ('/*...*/'), position the caret anywhere within the comment and press Ctrl+Shift+/.
  • When you typed some expression in the code and realized that you want to put its value into a local variable, just press Ctrl+Alt+V to do that.
  • Use Ctrl+Shift+F7 (ReSharper > Search > Highlight Usages), to easily see usages of a variable or another symbol.
    Use Ctrl+Alt+Up and Ctrl+Alt+Down to navigate between highlighted occurences. Press Escape to remove the highlighting.
  • When the caret is between the parentheses of a method call, pressing Ctrl+P brings up a list of valid parameters.
  • To surround a block of code with an if-statement, a loop, try/catch or another construct, select it in the editor and press Ctrl+Alt+J (ReSharper > Code > Surround With...). Choose the desired construct and press the Enter key.
  • Use ReSharper > Code > Reformat Code... to reformat code according to your code style preferences (see ReSharper > Options > Code Style).
  • To open source code of any type (class, interface, etc) in the editor quickly, press Ctrl+N (ReSharper > Go To > Type...) and start typing the name of the type (wildcard characters allowed). Choose the type from a drop-down list that appears.
  • A special variant of the code completion feature invoked by Ctrl+Alt+Space allows you to complete the name of any type no matter if it was imported in the current context or not. If the type is not imported yet, the appropriate using directive is generated automatically.
  • To navigate to the method overriden or implemented by the current one, position the caret anywhere within its declaration and press Ctrl+U (ReSharper > Go To > Base). This feature also works for classes and allow to jump to the base class or any of implemented interfaces. To use it position the caret is inside the class declaration but not inside any of member declarations.
  • Ctrl+W shortcut allows you to easily select different code constructs and logical code blocks.
  • Use F2/Shift+F2 keys to jump between highlighted syntax errors/warnings in the editor.
  • You can quickly navigate in the currently edited file with Ctrl+F12 (ReSharper > View > File Structure).
    It shows the list of members of the current class. Select an element you want to navigate to and press the Enter key.
    To easily locate an item in the list, just start typing its name.
  • Use Alt+Up and Alt+Down keys to quickly navigate between methods in the editor.
  • You can easily switch between a few recently viewed files with Ctrl+E shortcut.
  • To quickly jump to a usage of any symbol position the caret at the symbol's name and press Ctrl+Alt+F7 (ReSharper > Go To > Usage). It works similar to "Find Usages" action but does not show a tree with found occurences and is more convenient for quick navigation.
  • To quickly return to the last point where you did any changes in code, press Ctrl+Shift+Backspace. If you press it twice, you'll get to the previous editing point and so on.
  • You may easily comment a block of code either with line comments ('//') or with a block comment ('/*...*/'). Select the code to comment in the editor and press Ctrl+/ for line comments or Ctrl+Shift+/ for a block comment. When used with no selection Ctrl+/ comments the current line and moves to the next line.
    Use the same shortcuts to uncomment code.
  • You can use Ctrl+D shortcut to duplicate current line or selected text.

Labels: ,

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home