How-To's

ReSharper in Detail: CamelHumps

CamelHumps is a feature that identifies parts of compound names composed according to CamelCase, where each part starts with a capital letter (“hump”).

By default, it works in four navigation commands, namely Go To Type, Go To File, Go To File Member, and Go To Symbol, like this:

However, you should take an additional step to activate CamelHumps for the Extend/Shrink Selection (Ctrl + (Shift) + W, or Ctrl + Alt + Right/Left in the Visual Studio keyboard layout) and Next/Previous Word (Ctrl + Left/Right) navigation actions. To do that, choose ReSharper | Options | Environment | Editor and select Use CamelHumps.

From now on, CamelHumps is switched on, and jumping to next/previous word works in a slightly different manner. Specifically, when you press Ctrl + Left/Right, the caret moves to the next/previous uppercase character in the current word, and only after that, it moves on to the next/previous word.

Extend/Shrink Selection commands are also affected by CamelHumps. Suppose that the caret is in the middle of a compound word with several parts that begin with uppercase letters:

If CamelHumps is switched on, pressing Ctrl + W for the first time selects the current part of the word:

It’s only after pressing this keystroke for the second time that you can select the whole word:

All subsequent keystokes are processed as usual.

In addition, ReSharper provides four actions for using CamelHumps locally when the global option (Use CamelHumps) is switched off:

  • 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

Of course, you can assign individual shortcuts to these actions in the Visual Studio Options dialog box (Tools | Options | Environment | Keyboard).

Note that both HumpNextExtend and HumpPrevExtend only work in a linear fashion, without additional functionality of Extend/Shrink Selection.

Technorati tags: ReSharper 3.1, ReSharper in Detail, ReSharper, CamelHumps, Extend/Shrink Selection, Next/Previous Word, Go to
image description