I blog about ReSharper a lot, mostly due to it’s being an awesome product which greatly improves my productivity. One of the major tips any ReSharper user is given – use the keyboard shortcuts. A lot. Some even go completely mouseless!
Here’s a little tip to make navigation your code even better: CamelHumps. CamelHumps is a ReSharper feature that allows navigating and selecting parts of compound names, according to camelCase rules, so that if you have a method named
CreateUser_WithValidUsernameAndPassword_UserIsCreated (like I name my unit tests,
UnderTest_Scenario_ExpectedResult), with CamelHumps enabled, you would be able to move the caret to the beginning of every word using Ctrl-Left/Right.
While this is a great feature, I wouldn’t want it enabled all the time, since it’s also affects Extend/Shrink Selection (Ctrl-W), which sometimes can be annoying. Fortunately, those actions are available as Visual Studio actions, so they can be used even if CameHumps is turned off globally:
- ReSharper_HumpNext – move caret to next hump/word
- ReSharper_HumpPrev – move caret to previous hump/word
- ReSharper_HumpNextExtend – expand selection to next hump
- ReSharper_HumpPrevExtend – expand selection to previous hump
I recommend binding the ReSharper_HumpNext and ReSharper_HumpPrev to Alt-Right and Alt-Left, and ReSharper_HumpNextExtend and ReSharper_HumpPrevExtend to Alt-Shift-Right and Alt-Shift-Left, respectively. Make sure you select Text Editor under “Use new shortcut in” in Tools – Options – Keyboard, or your binding might not work.
Please note: the later binding breaks the Box Selection feature in Visual Studio 2008, however greatly improves it in Visual Studio 2010 – it makes box selection respect the camelCase as well!
Here’s how it works – let’s say I want to rename the word Spelling to Proofreading in the method name, and the caret is inside the method body:
Step 1: Press Ctrl-[ to jump to containing method (jumps to start of the method name)
Step 2: Press Alt-Right a few times to jump to the beginning of the word Spelling
Step 3: Press Alt-Shift-Right to select the word Spelling
I’m using Roy Osherove’s excellent Keyboard Jedi utility to demonstrate the keyboard shortcuts. Unfortunately it doesn’t work on a 64-bit Windows, but you can fix it with this little hack by James Kovacs.
Unfortunately, this doesn’t work in the rename dialog (and others). There’s a 3-year old issue reported on the ReSharper’s Issue Tracker about this, however it hasn’t been added yet. Maybe it’s time, guys?