Welcome to day 14 of my 31 Days of ReSharper.
ReSharper replaces Ctrl+Space with its own version. It mostly does the same thing as Visual Studio’s Ctrl+Space, but it has one additional feature: it can suggest variable names for you.
If you type a variable declaration, and hit Ctrl+Space…
ReSharper shows an AutoComplete dropdown with suggested names, based on the type name. The dropdown list behaves like any other AutoComplete dropdown, so you can cursor to an item and hit Enter, or you can just type
; and it will accept the current selection and type a semicolon.
It’s smart enough to ignore the leading
I on interface names. And if the type is only one word, it won’t bother with the dropdown. So if you type
ISprite (space) and hit Ctrl+Space, it will go ahead and fill in
Of course, this isn’t just for local variables; it also works for parameters and fields. You can even teach it your naming conventions, e.g. if all your fields’ names should start with
_; see the Naming Convention page in ReSharper Options.
You can also type in a prefix before you press Ctrl+Space:
Unfortunately, this has a bug in ReSharper 2.5.1. Notice that the suggestions have turned my prefix into all-lower-case, instead of keeping the camelCase that I had originally typed. (They’ve created a ticket for the bug.)
The variable name suggestions aren’t limited to Ctrl+Space when you’re declaring a variable; they appear other places in ReSharper as well. For example, when you’re introducing a parameter, you get a combo box where you can either type a name, or select one of the suggestions. When you’re renaming a variable, the name suggestions pop up. When you’re extracting a method, the suggestions kick in for the parameter names. Etc.