A Portion of Buff

Everybody else had one, so...

February 2004 - Posts

Jetbrains 'ReSharper'

Jetbrains briefly posted a feature list for the first beta of their VS.Net plugin (hopefully out this week), and then pulled it. Watch me get in trouble for posting it here (excuse the lack of formatting):

ReSharper is a Visual Studio .NET add-in which facilitates everyday code development tasks. Currently it mainly targets code navigation, search and insight. In the near future it will support refactorings and more outstanding code modification and insight features.

Navigation

Navigation is one of the most frequently used groups of features, so we discuss it first.In ReSharper one can go to a declaration, base or inherited element, variable type, etc. using a single keyboard shortcut which is much simpler than to dig to drop-down menus.

Action Shortcut Description

Go to Declaration Ctrl+B Position the caret at usage of any symbol and use this action to jump to its declaration

Go to Inheritor(s) Ctrl+Alt+B Position the caret at usage or on the declaration of any type (class, interface, etc) and use this action to navigate to its inheritors.

- or -

Position the caret at usage or on the declaration of any method (as well as property, indexer, etc) and use this action to navigate to methods overriding (implementing) this one.

Go to Base Ctrl+U Position the caret within declaration of any method (as well as property, indexer, etc) and use this action to navigate to method(s) this one overrides(implements).

- or -

Position the caret on declaration of any type and use this action to navigate to its super types.

Go to Type Declaration Ctrl+Shift+T Position the caret at usage of any variable and use this action to jump to the declaration of its type

 

You can also use the following shortcuts to quickly open any classes or files for editing:

Action Shortcut Description

Go to Type Ctrl+N Invoke this action and type in a few first characters of some class (interface, etc) name. It will bring you list of all types whose names match entered prefix and you'll be able to quickly navigate to the desired type. You can also use wildcard ('*') characters (e.g. enter "*Test" for all types which have "Test" in their names).

Go to File Ctr+Shift+N Same to Ctrl+N, but displays list of files in the solution

 

Finally, we have the following in-class navigation shortcuts:

Action Shortcut Description

Go to Previous Method Alt+Up Go to previous method (property, operator, etc)

Go to Next Method Alt+Down Go to next method (property, operator, etc)

 

Search

To search for usages (inheritors, implementing classes, etc.) of any symbol position the caret at its usage or on its declaration and press Alt+F7. Found results are displayed in Find Results View. They are organized there in tree where you can change grouping, merge occurences, filter out reads/writes, etc.

Another useful action is Highlight Usages. By pressing Ctrl+Shift+F7 you can highlight usages of the symbol you're standing at in the current file. It is mostly useful for local variables but can also be used for any other symbol. It highlights reads and writes with different colors, so you can easily see where you assign or read a variable or property.

You can use Ctrl+Alt+Up/Ctrl+Alt+Down to navigate between occurences found by either Alt+F7 or Ctrl+Shift+F7. Note that these shortcuts work for selected find results view even when focus is in the editor pane.

File Structure

You can easily view structure of the file you're currently in by pressing Ctrl+F12. You can navigate in this list by typing first letters of the member you're looking for.

Refactorings

The first EAP version has only one refactoring - rename refactoring (more refactorings come soon!). Rename refactoring is called with Shift+F6 shortcut. You can invoke it from the editor when caret is at the declaration or on usage of the symbol to be renamed. You can also use it from VS views like Class View or Object Browser.

Parameter Info

Position the caret within argument list of some method call (or new operator, indexer etc) and press Ctrl+P. A small popup window with list of available signatures is displayed.

Code Completion

Code completion tries to predict which code is appropriate in the current context making code writing faster. There are three kinds of code completion:

Action Shortcut Description

Basic Completion Ctrl+Space Diplays list of symbols available in the current context.

A special case of this completion works for completion of variable name when you declare it. For example, you may type in "ArrayList color", press Ctrl+Space and get "colorList" and "colorArrayList".

SmartType Completion Ctrl+Shift+Space It detects the type which is expected in the context and suggests only choices that match the expected type. It works on the right hand of assignments, in argument lists of method invocations, in return statements and other places where expected type is known.

Special variants of this completion work after "new" keyword allowing to instantiate the expected type and for type casts (after '(' or "as" keyword) casting to the expected type.

Type Name Completion Ctrl+Alt+Space This type of completion displays the list of all types matching the entered prefix independently from using directives in the current file and when you select an item it inserts the necessary using directive if needed.

 

IMPORTANT: If you want the completed item to replace the existing code, use Tab key to complete item instead of Enter. For example, if you have the following code:

 

e.{Caret here} foo();

and want to replace foo with bar, press Ctrl+Space, choose "bar" from the list and press Tab.

Live Templates

Live Templates are pieces of code which can be inserted into the code and are automatically customized to match the context they're called in. A live template can be called by typing its "abbreviation" (a short mnemonic sequence of letters associated with template) and then pressing the Tab key to insert the template. Another way is to use Ctrl+J shortcut which lists available templates with abbreviations matching the entered prefix. To see all available templates just press Ctrl+J on a blank line. Currently the set of available templates is fixed but soon users will be able to define their own templates.

Surround With

This feature allows you to quickly put the selected code fragment into if-statment, loop or code block. To try it select a few lines of code and press Ctrl+Alt+J.

Error Highlighting

As you type code ReSharper analyses the code "on-the-fly" and automatically highlights syntax errors such as unresolved symbols, mismatched types or uninitialized variables. Soon all errors detected by the compiler will be highlighted and you will not need to run the compiler to test correctness of your code.

Syntax Highlighting

For better understanding of the code ReSharper provides highlighting of different kinds of symbols in code (fields, locals, classes etc) in different manner. You can configure highlighting settings in the standard VS.NET highlighting setup page ( Tools > Options > Environment > Fonts and Colors ).

Brackets Matching

Brackets matching is another intuitive feature. Put the caret right after '}', ')' or ']' in the code and see the matching bracket. The same for the caret right before the openning bracket.

Brackets and Quotes Auto-insertion

Another cool feature: when you type '(', '[', double quote or single quote character a pair character is inserted automatically (when makes sense). It can be disabled but don't hurry going to the options to turn it off if you're afraid that you will be frustrated by extra brackets you'll have to skip. It moves you over the matched bracket if you try to type an extra one.

Options

At last, all ReSharper options are available in the standard VS.NET options area: Tools > Options > ReSharper.

More Posts