Coding Assistance
Syntax Highlighting
ReSharper extends the default highlighting support of Visual Studio with highlighting for fields, local variables, types, and more, in both C# and VB.NET. For example, the Syntax Highlighting feature allows you to easily distinguish between local variables and fields in your code. To switch on ReSharper's highlighting, choose ReSharper | Options | Code Inspection | Settings and select Color Identifiers.
Context Actions
Context actions are shortcuts to different ReSharper features that are displayed right in the code editor when you work with C#, VB.NET, XML, ASP.NET, HTML, Razor or JavaScript code.
Context actions may suggest executing minor code transformations, refactorings, or navigation actions.
Whereas quick-fixes are intended to fix errors and less serious code issues, context actions just give references to ReSharper features that can be applied at a certain code position. Whether you use the suggested context actions or not is entirely up to you.
Availability of context actions for a code position is designated by one of the following icons to the left of the current line:
for code editing actions.
for refactoring actions.
for code generation actions.
for surround actions and
surround templates (appears when you select a code block).
for navigation actions.
You can either click an icon or press Alt+Enter, and then select an appropriate action.
You can enable or disable specific context actions for C#, VB.NET, XML, ASP.NET, HTML, Razor or JavaScript in the ReSharper Options dialog box.
Code Completion
ReSharper complements and extends Visual Studio's native code completion (IntelliSense) with more advanced capabilities. For example, it narrows down the list of suggestions based on your typing, automatically imports selected types and extension methods, adds parentheses when completing method names, suggests variable and field names depending on their types, and so on.
All completion features support CamelHumps — that is, you can complete any item by entering only its uppercase characters.
Symbol Completion
Ctrl+Space code completion recognizes variables and methods, currently visible type names, keywords, and more. ReSharper automatically suggests prefixes when declaring identifiers, according to your coding guidelines.
Starting from version 5, ReSharper provides completion for unresolved symbols in local scope: even if a code symbol is not declared, ReSharper grabs its known members from its usages (see screenshot below).
In ASP.NET files, ReSharper also provides code completion for web control properties and events, data sources, content
placeholders, and of course, inline C# code.
When it comes to XAML, you have assistance with references
to resources, whereas in build scripts, ReSharper helps you with property, target, task, and
attribute names that are available within the current scope.
Smart Completion
Smart Code Completion, invoked with Ctrl+Shift+Space, filters the list of methods
(functions in VB.NET), fields or variables to match the expected type of an expression. For example, when you
use Smart Completion for method call arguments, the list of suggested values is narrowed down only to the
required parameter type. Smart Completion can also suggest creating anonymous methods, lambda expressions, and
regular methods, as well as local variables for out parameters.
Smart Completion works like a charm in XAML
event handlers and other positions.
Import Symbol Completion
Import Symbol Completion (formerly Type Name Completion) is invoked with Ctrl+Alt+Space.
Unlike Symbol Completion (which only completes types accessible at the current location), ReSharper displays all
types that match a specified prefix regardless of what namespace they belong to, and automatically adds the
appropriate namespace import directives when necessary. In C# code files, Import Symbol Completion works
after dot with extension methods and puts necessary using directives.
Import Symbol Completion in very
helpful in XAML markup for tag names. Namespace import directives are also inserted as required.
Complete Statement
Complete Statement, introduced in ReSharper 4, is a feature that inserts necessary syntax elements (braces, semicolons etc.) and gets you to the position to start the next statement, saving you from excessive juggling with the caret. As you work, keep in mind the default shortcut for this feature: Ctrl+Shift+Enter.
Complete Statement (also known as Smart Enter) comes to rescue in numerous scenarios, including auto-closing parentheses, adding semicolons, completing if, while and for statements, and so on.
For example, whenever you declare a new method, Complete Statement comes handy after specifying method parameters:
If you press Ctrl+Shift+Enter at this point, ReSharper will automatically insert a closing parenthesis, as well as both braces, and put the caret right where you can proceed with writing the method body:
Extended Naming Style Configuration
ReSharper lets you define custom naming style settings for different languages and symbols including types, namespaces, interfaces, parameters, method properties and events, static and instance fields etc.
For every kind of symbol, you can configure one of five casing options, prefixes and suffixes, variations for different access rights, abbreviations to preserve, and other options.
When you have a custom naming style, ReSharper:
- Keeps your specific naming guidelines in mind when it provides code completion options and generates new members.
- Displays warnings when it detects members that don't comply with your naming style.
In addition, starting from ReSharper 5, you can browse through (and quickly fix) all naming style violations in your whole solution (or in a narrower scope) in the Inspection Results window by using the Find Code Issues feature:
Parameter Info
This part of Visual Studio's IntelliSense is also extended in ReSharper. When you call a method (procedure), Parameter Info shows you all available method signatures and parameters with relevant documentation (the tooltip appears automatically while you type, or you can display it by pressing Ctrl+P). While you are adding new arguments, ReSharper grays out any signatures that become incompatible.
Highlight Matching Delimiters
In C#, whenever you place the caret immediately before/after a closing parenthesis/bracket/brace, the matching opening character is highlighted, and vice versa (this option is configurable).
In VB.NET, the matching Sub or Function is highlighted when the caret is placed anywhere within or after End Sub or End Function. The matching keyword and its line are highlighted whenever you place the caret within the opening keyword (again, you can fine-tune this feature).
In XML, matching tags are unobtrusively highlighted, letting you see the
tag structure.
If a matching piece of code scrolls off the screen, an appropriate pop-up appears for your
convenience.
Importing Namespaces
When a type name cannot be resolved because you forgot to issue the corresponding namespace import directive in the source code, a small pop-up appears to suggest one or more types to import. Simply press Alt+Enter, and the appropriate namespace import directive will be inserted automatically. Also, you will not lose your current caret position.
For markup files in web applications, ReSharper is able to auto-import user controls (ascx files) based on their usages.
Auto-insertion of Delimiters
When you type (, [, ", or ' in the editor, a paired character is inserted
automatically (whenever appropriate). This feature may be easily switched off, but you shouldn't be afraid of
inserting too many closing parentheses, brackets, or quotes by mistake: if the closing parenthesis or quote
already exists, ReSharper will not add the second one.
In XML, as soon as you type an opening quote or
bracket, the closing one appears automatically.
Code Reordering
ReSharper allows you to quickly change the order of code elements with the press of a key — well, four keys: Ctrl+Shift+Alt+Up/Down/Left/Right. In particular, you can move members up and down, reorder method parameters, move statements within a block, move statements out of or into a block, move XML tags up and down, as well as XML attributes left and right.
Quick Documentation
To see the documentation for a certain class, method/function or other symbol right in the editor, position the caret on the symbol name and press Ctrl+Q. The documentation shows in a pop-up window with clickable links to other resources.
Comment/Uncomment Code
Promptly comment or uncomment any block of C# or VB.NET code by selecting it in the editor and pressing Ctrl+/ (for line comment) or Ctrl+Shift+/ (for block comments in C#).
You can also use Ctrl+/ to quickly comment or uncomment the line of code where the caret is located in the editor if no block code has been selected. In the same circumstances, pressing Ctrl+Shift+/ inserts the opening block comment (/*) and the closing block comment (*/) immediately before and immediately after the caret position, or removes them if the caret is positioned inside the commented code block. You can also use this feature to insert comments in XML and XAML files.
Highlight Current Line
You can opt to highlight the line where the caret currently resides with a color. Just select Hightlight current line in the Editor tab of the ReSharper Options dialog box:
You can configure the color of the highlight in the Fonts and Colors tab of the Visual Studio Options dialog box (Tools | Options ).
Extend/Shrink Selection
The Extend Selection feature helps successively select expanding blocks of code. That is, you can easily select any expression in the code by placing the caret somewhere inside it and pressing Ctrl+W a few times. Shrink Selection works in the opposite way and can be applied by pressing Ctrl+Shift+W.
Duplicate Line or Selection
Quickly duplicate any line (block) of code by placing the caret at this line in the editor (or, respectively, selecting the desired block) and pressing Ctrl+D.
Multiple Entries Clipboard
ReSharper provides a special Paste command that launches the Multiple Entries Clipboard window. It contains references to recent clipboard items, each marked with a figure or letter, which you can easily select between.
Note:
All keyboard shortcuts provided in the "Features" section are taken from ReSharper 2.x / IDEA keyboard scheme. For details on ReSharper's two default keymaps, see Documentation and Demos.