Just like the new Visual Studio 2015 Light Bulb, the Rename feature is an IDE improvement you may have seen before as part of an extension. ReSharper and CodeRush users have been happily renaming for a while now, and there’s a reason it’s an often-used feature. Any refactoring operation is likely to involve some renaming, and having to do it just one time (without having to roll the dice with a find/replace) is so much faster! Now the rest of us can rejoice – Rename is built-in to Visual Studio 2015 and I like it better than any other method I’ve tried.

Rename refactoring can be accessed through the context menu, by using the shortcut Ctrl+R, or may be given as an option in the Light Bulb Quick Action menu. And similar to the Light Bulb, there is a friendly Preview Changes option that might save you a few Undo actions in the future. You can specify the scope of the Rename here, select/unselect classes, and preview individual changes.

2015-10-16 15_20_22-VS2015TipsDemo - Microsoft Visual Studio

Once the Rename is activated, just start typing the new name in-place, and Rename will take care of the rest – highlighting other instances in the same file, and warning you of conflicts.  Select your options and click Apply to finish the rename action.

2015-10-16 15_20_01-VS2015TipsDemo - Microsoft Visual Studio

It’s also a lot smarter than you may realize. If Visual Studio 2015 detects that you just renamed a method, for instance, the Light Bulb will show up and give you the option to do a full ‘Rename’ operation.

2015-10-16 15_42_23-VS2015TipsDemo - Microsoft Visual Studio

The Light Bulb will also expand into a sort of preview pane itself, showing the changed items inline. This is another useful view I haven’t seen before – this makes it easy to see what will change when the operation is completed.

2015-10-16 15_58_34-VS2015TipsDemo - Microsoft Visual Studio

Making Rename an in-place operation is just another piece of this new set of Visual Studio 2015 features that help make refactoring a smooth part of the development cycle. And that makes this developer pretty pleased.

The following two tabs change content below.

Latest posts by Falafel Posts (see all)