null
null

Reputation: 3517

IntelliJ Automatically create private fields / methods like in Visual Studio?

In Visual Studio 2012 I can type something like aString = ''. This variable hasn't been declared as yet and by pressing ctrl + . the IDE is wonderful enough to create a private datamenber named aString of type String.

Is there a feature that mirrors this in IntelliJ?

I found an option for auto inserting methods on https://www.jetbrains.com/idea/features/code_assistance.html but couldn't find anything relating to private fields.

I don't have access to the IDE at the moment before anyone suggests the obvious :)

Upvotes: 3

Views: 1002

Answers (2)

maba
maba

Reputation: 48075

Another way of doing it is by first typing only "" and then .var.

This is called Postfix Code Completion and is very useful. There are lots of other completions other than the .var one. I often use the .cast postfix completion for example.

Use it like this:

enter image description here

enter image description here

enter image description here

Then you just start typing the name of your variable:

enter image description here

And finally there it is your complete line:

enter image description here

Upvotes: 3

traveh
traveh

Reputation: 2884

Absolutely.

If you write aString = "" and you click alt-enter you'll get an option to create a field (private by default) for it along with several other options.

enter image description here

Upvotes: 3

Related Questions