简体   繁体   中英

Surround with suggestions from auto-complete in Intellij?

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?

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.

In mac it is command + shift + enter

That will surround sa with the completed code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM