Reputation: 9159
Suppose you have the following method
void consume(List<String> list) { ...
And somewhere you have, and want to call the method from above.
String sa = "whatever";
If you type:
sa
and then put the cursor before sa
and want to autocomplete
Collections.sing
|sa
then CTRL+Space then Enter
what you'll get is
Collections.singletonList()sa
and you want Collections.singletonList(sa)
Is there a way to automatically surround the variable with what auto-complete returns?
Upvotes: 3
Views: 195
Reputation: 955
In mac it is command + shift + enter
That will surround sa with the completed code.
That action is called complete current statement, ctr + shift + enter on windows with the default keymap.
Upvotes: 1
Reputation:
Not exactly what you're looking for, but you can get a bit closer with postfix completion. After typing sa
and realizing that you want to call a method on it, you can type .par
Tab to put the parenthesis around it, then Home to go back to the start of the line and you can type Collections.sing
Tab to complete the method call.
That is, I think completion works the way you want if you put the parenthesis around the argument first. I'm not aware of a better way, though I'd be fine to be proven wrong.
Upvotes: 0