Autocomplete variable name

Hi,     

I've searched the web and the forums but can't see any answers on this so hoping for a nudge in the right direction here. Here's the scenario:

When I create a new variable that'll ultimately look like this ............... Person person = new Person();

When I have type Person and type in the p of the variable name or hit Ctrl+Space I get a list of suggested names. The default one never seems to be the right one for me and I'd ideally like it to autocomplete the variable name by following a rule like lowerCamelCase. I can't figure out exactly where I can enter this so it always defaults to this or even autocompletes it without giving me a choice. Any ideas?7

Thanks in advance.

4 comments
Comment actions Permalink

Is your naming style for "local variables" set to use lowerCamelCase? (in your ReSharper->Options->Common->Naming Style, or a style for your specific language).
(And make sure you don't override it with a user defined naming rule that doesn't use lowerCamelCase ).

0
Comment actions Permalink

Thanks for your reply. Yes, I do have that set as lowerCamelCase but I still get several options, the default one being incorrect:

For example for variable type PersonTestObject I get the following options:

- o
- O
- operator   (default)
- personTestObject
- PersonTestObject
- testObject
- TestObject

I just want it to either default to personTestObject or just auto-insert this, any ideas?

0
Comment actions Permalink

FWIW, I'm using 4.5 and get what I guess similar behavior.


temp.pngand temp.png

RS seems to select the default value based on most usage as Serge writes in this post: http://www.jetbrains.net/devnet/message/5237626#5237626 .
But hopefully you get a proper answer of how to get around it :-).

*Edit: Hrm the above post was for the autocomplete for intellisense. I don't think the same logic exists for suggested variable names since I don't recall ever using "o" as a variable name...

0
Comment actions Permalink

Have you thought of using "Jedi-Coding"?

Type "new Per<ctrl+space>" to get "New Person()

Now type the key for the "Introduce Variable" refactoring.

You should end up with "var person = new Person();"

I do this with all my variable assignments  these days, especially those
with "new".  Write from the back end (value) first, and then hit one
keystroke to have it add the variable declaration.  It almost always guesses
the right name for me.


"Rick Blyth" <no_reply@jetbrains.com> wrote in message
news:10107849.72431274435614774.JavaMail.clearspace@app8.labs.intellij.net...

Hi,

>

I've searched the web and the forums but can't see any answers on this so
hoping for a nudge in the right direction here. Here's the scenario:

>

When I create a new variable that'll ultimately look like this
............... Person person = new Person();

>

When I have type Person and type in the p of the variable name or hit
Ctrl+Space I get a list of suggested names. The default one never seems to
be the right one for me and I'd ideally like it to autocomplete the
variable name by following a rule like lowerCamelCase. I can't figure out
exactly where I can enter this so it always defaults to this or even
autocompletes it without giving me a choice. Any ideas?7

>

Thanks in advance.

>

---
Original message URL:
http://www.jetbrains.net/devnet/message/5263700#5263700


0

Please sign in to leave a comment.