A View Inside My Head

Jason's Random Thoughts of Interest

NAVIGATION - SEARCH

CodeRush: The Refactor Key

Do a search, and you will find that there are a few IDE Productivity Tools available for Visual Studio. As far as feature sets go, you'll also find that there is quite a bit of overlap in what these tools offer.  So, deciding on one is largely a matter of personal preference. 

However, by not using an IDE Productivity Tool at all, you are doing yourself a great disservice.  No, really!  You are wasting a lot of time by manually doing things instead of allowing software do it for you.  Since time is money, and these tools are not very expensive, you will quickly make up for the cost of the program in time savings alone (I think within the first week, if not the first day).

The one tool that I stand behind is CodeRush by DevExpress. Some of the finest people in the industry work for Devexpress, and over the years, some of these folks have become quite good friends of mine.  The company has an outstanding commitment to supporting the developer community year after year, and you will surely find them sponsoring a developer event near you.  Aside from the goodwill, their product suite is outstanding, so I'm proud to continue to use and recommend their entire product line whenever I can.

Sidebar: Personally, I think that DX has a bit of a branding problem with their IDE Productivity Tools, because CodeRush includes another product called Refactor! Pro.  I would rather see them not offer Rafactor! Pro by itself, and only sell CodeRush with Refactor! Pro, since in my mind they are together one product (and I would never recommend Refactor! to someone without CodeRush).  As such, I often refer to features from Refactor! as belonging to CodeRush.  But, I digress.

Learning any new tool can be a bit daunting at first, and CodeRush is certainly no exception.  DevExpress has produced a collection of short tutorial videos to help new users come up to speed.  It should be noted, though, that some of these videos are likely useful to experienced users as well: with so much functionality packed into the product, I find that it's common for someone to master a number of features, be familiar with just as many if not more features, and yet be totally unaware of half of the things that the tool has to offer.

Since you have to start somewhere, the first feature that I recommend that someone master is mapping and using their Refactor key.  This is a shortcut key that will open a CodeRush "context menu" to show available refactorings for the code where the cursor is currently located. 

Personally, this is the feature that I probably use the most, so finding an appropriate key binding that is easy to hit yet does not interfere with my ability to type code or use Visual Studio key bindings was important.  The default is Ctrl-backtick ( ` ), but I landed on the just backtick key to save me from needing to hold Ctrl.  I've heard of a few people who have picked F1 as a way of defeating the annoying help system in VS2008 and earlier.  It's all a matter of personal preference, so choose something that works for you.

To set the Refactor key shortcut, open the Options from the DevExpress menu in Visual Studio.  In the tree on the left, open IDE and click on Shortcuts.  After admiring the entire collection of shortcuts that are available, locate the "Refactor!" section in the list.  One of the defined shortcuts will be mapped to the "Refactor" command, and by clicking on this, you can set your own key to bind it to on the right.

Refactor key binding is set in the Visual Studio Devexpress Menu, Options, IDE - Shortcuts - Refactor! group

Trivia: Notice the Alternate Bindings that also appear in the same section. Number Pad 0 is the one preferred by Mark Miller.  Dustin Campbell has two bindings mapped: the default Ctrl-`, as well as Number Pad INS.

Now that you have a Refactor key, try moving your cursor to different places in your code and pressing it. 

Refactor key pressed on a variable

You'll still have to learn about different refactorings that are available in the tool, but hopefully the Refactor key will become your preferred portal for accessing those refactorings (instead of using smart tags or the mouse to right-click on code).

Happy Coding!

Pingbacks and trackbacks (1)+