So you’ve just been handed a copy of CodeRush and told that it’s the future.. Whomever told you this, is very insightful and deserves much of your respect :D
After installing, the first thing you should do, is to give CodeRush an idea of how you like things done. I have decided to compile this little list of the options that I change and why, in the hopes that this will help ease you into working with your new best friend.
So options… where are they then?
Access to the options screen is granted via the options entry on the DevExpress menu.
If you see no DevExpress menu, then you either don’t have CodeRush installed, or you are running the Xpress version (I think MS asked that it not have the DevExpress menu)
If this is the case, you have 2 options…
- Suck it up and hit Ctrl+Shift+Alt+O and your options should appear.
- Bust out RegEdit and go to town on your registry. (Note that the latest version is 9.2 not 9.1)
Ok so now you’re into the options screen. Each page (on the left in the tree) is created and dynamically added to this tree by the plugin that it represents. This means that as a plugin developer I can seamlessly add pages to this tree for my own plugin.
Additionally some of the options pages are considered Advanced or Expert rather than the default of New User. see the little Level dropdown in the bottom left of this screen to alter your current setting. Further, some pages are language specific, so you’ll need to set the Language dropdown (a little to the right of the level dropdown) to the language you’re looking to configure.
So what settings do I alter?
Code Style (Editing\Code Style\Identifiers)
There are a few pages under Editing\Code Style which you should definitely browse through. I generally find the default to be more than satisfactory. However my own personal preferences differ slightly on the Identifiers page. I prefer Pascal Case for everything, but will prefix fields with an ‘m’ (for module level). This is purely a readability issue.
Organization(Editor\Organization\Member Mover)
This relates to the “Move to Region” function under the little icon to the left of each of your method signatures. If clicked, it presents you with a list of regions into which you might wish to move the method in question.
This list contains regions that already exist with the current code file. The options page allows you to preconfigure an additional list of regions which will appear in this menu, regardless of whether or not they already exist in the code file.
I tend to configure the following regions (each on a separate line)
Fields
Constructors
UI Events
Extraction and Generation
There are several places in the options where CodeRush gives you the option to specify the location where generated code will appear, relative to your current position. I don’t like having to tell CodeRush where to place generated items each and every time. I’d far rather set up a default.
Therefore:
Create Method Stub (Editing\Refactorings\Create Method Stub)
Insert Method: After source method property.
Extract Method (Editing\Refactorings\Extract Method)
Insert new methods: Below the source method or property.
Extract Property(Editing\Refactorings\Extract Method)
Insert new properties: Below the source method or property.
Property To Method (Editing\Refactorings\Property To Method)
Insert method(s): After the source property.
Decompose Initializer (Editing\Refactorings\Decompose Initializer)
I don’t like an automatic “With block” so I turn this off (VB.Net Only)
Early Experience(Editing\Refactorings\Early Experience)
Hell Yeah :D – The bleeding edge is where it’s at :) but perhaps this does not suit everyone.
Encapsulate Field(Editing\Refactorings\Encapsulate Field)
Insert New Property: Below the field. (Similar logic to other extractions)
When references to the field exist : Do not Replace anything.
I use properties for external access to a field. If I’m accessing the property from inside the class it’s a special case rather than the rule.
Templates (Editor\Templates)
I have always maintained my own little set of templates which I store in a Custom root folder. These need to be imported if I am starting from scratch. I suggest that you place any new Templates you create in a similar “Custom” root folder. This makes the export and import of these templates, all the easier.
Shortcuts (IDE\Shortcuts)
I like to place new shortcuts in a Custom folder. you’ll see a pattern in several of my choices for common keys. This is because I am already so well trained in the art of Alt+Tab
I assign Alt+` to CodeRushTrainingWindowToggle which allows me easy reach of said window, whenever I Forget something.
I assign Alt+1 to Refactor.
I assign Alt+2 to Navigate. I don’t use this as much as I’d like, but I’m learning (We never really stop learning eh?) Not got used to it yet, but I figure it’s the best place for it, given it’s proximity to Alt+1
I assign F2 to Refactor with a parameter of Rename. Ironically this is so that I don’t have to learn another shortcut. It is already deeply ingrained within me that I can rename a folder/file in windows explorer with F2, so it seemed like a good fit. this particular shortcut is already in CodeRush but is disabled. You can find it in the IDE\Shortcuts options page. In the 'Refactor!\Alternate Bindings' folder.
I guess that’s it for now. I’ll try to keep this post up to date with various changes I make to these settings. I assume there’s someone out there who’ll benefit :)
3 comments:
Great Post Rory. Is there any way to export these settings or back them up, so we don't have to reset them every time? I just posted something similar about visual studio 2008 http://techsoda.wordpress.com/2009/09/29/getting-visual-studio-2008-to-my-preferred-state/
Thanks man :)
Since 9.2 all settings (AFAIK) are stored in the "Settings.XML" folder.
You can locate this folder through the settings button in DevExpress\About.
Alternatively, Try "%AppData%\CodeRush for VS .NET\" in your Windows explorer address bar.
These settings are yours. This is the folder I would back up. The folder can be removed entirely and CodeRush will rebuild them from a seperate store.
Hope this helps :)
I just installed 9.2.6 and I must say it is pretty sweet!
Post a Comment