How to generate return value type and variable assignment in Eclipse java editor?
What is wrong with Ctrl+2, L. With Tab and ↓/↑ ?
Ctrl+2, L
is one option, and the other is Alt+Shift+L
when the desired statement is selected. The popup will appear allowing to set variable name & few additional options (e.g., "Replace occurrences of the selected expression with references to the local variable").
I prefer Alt+Shift+L
because it allows marking specific part of the line for variable extraction.
.. and here's a simple example:
..
new FileInputStream(new File("test.txt"));
..
You can select the whole line to assign it to FileInputStream
variable, or you can 'extract' new File("test.txt")
, or even String expression "test.txt"
.
P.S. Sometimes I wish it would be able to let me choose supertype from combo box in a pop-up, e.g. InputStream
in this specific example.
CTRL=2,L will do what you are looking for.