简体   繁体   English

周围环绕着 Intellij 中自动完成的建议?

[英]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然后将光标放在sa之前并希望自动完成

Collections.sing | Collections.sing | sa then CTRL + Space then Enter sa然后CTRL +空格然后Enter

what you'll get is你会得到的是

Collections.singletonList()sa and you want Collections.singletonList(sa) Collections.singletonList()sa和你想要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 .不完全是您要查找的内容,但是您可以通过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.输入sa并意识到要对其调用方法后,可以输入.par Tab将括号括起来,然后输入Home回到行首,然后输入Collections.sing Tab来完成方法调用。

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在 mac 中是command + shift + enter

That will surround sa with the completed code.这将用完整的代码包围 sa。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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