How to perform a code refactoring using IDE tools
There are several methods which allow you to perform a particular refactoring. Multiple methods are provided to ensure that you feel comfortable inside the Visual Studio IDE. These approaches are available:
- The Refactor! popup menu (shown via a single shortcut)
There is a built-in shortcut that invokes the Refactor! popup menu and lists all available refactoring/code operations for the current caret position and/or code selection. The default shortcut is the CTRL+` (back tick) key combination. Note, that you can configure the shortcut to immediately apply a refactoring if only one operation is available. See the “IDE tools smart tag” section below to learn more about possible options.
You can also create custom shortcuts to invoke the specific refactoring immediately, without having to go through the popup menu. To learn more, see the “How to assign a separate shortcut to a particular refactoring” topic.
- DXCore smart tag (and/or Visual Studio’s smart tag)
The other way of invoking the Refactor! popup menu is to click a DXCore smart tag. The type of a smart tag style is configurable, so you may use the built-in Visual Studio’s smart tag instead. You can tweak lots of the DXCore smart tag’s options on the “Smart Tags” options page in the Options Dialog. The page allows you to choose whether to use the DXCore or Visual Studio’s smart tag, appearance of the DXCore smart tag, presence of smart tag items in the Visual Studio’s context menu and the default behavior of the smart tag shortcut, when only one operation is available.
- Visual Studio’s context menu
IDE tools integrate their items into the Visual Studio’s code editor context menu. You can configure adding these items on the same “Smart Tags” options page above.
Some refactorings/code operations can be applied by cutting a particular code block and pasting it at a particular position. This feature is only available for a small subset of refactorings that involve moving code blocks. These refactorings are:
- Extract Method
- Introduce Local
- Declare Method
Note: you can control the availability of Intelligent Paste and its behavior via the “Editor | Clipboard | Intelligent Paste Setup” page in the Options dialog. The page allows you to change the maximum number of lines that you can cut and paste to apply the Intelligent Paste feature.—– Products: all Versions: all VS IDEs: any Updated: Mar/14/2011 ID: R015