Yep! This is the Introduce Variable refactoring. By default, select some text, and then hit Ctrl + Alt + V (for Mac: ⌘+⌥+V). If the expression is incomplete or invalid, IntelliJ will still make a good guess about what you meant and try to fix it for you.
IntelliJ 13.1 introduced Postfix completion.
With Postfix Completion you can introduce a local variable by typing:
MyObject.getValue().var
and pressing ctrl + space
or enter
.
It even works inside other statements. For example:
foo.someMethod(myObject.getValue().var);
for mac users:
alt + enter
at the position where you want to generate your variable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With