IntelliJ autocomplete to replace the function name

有些话、适合烂在心里 提交于 2020-08-21 05:03:09

问题


I've switched from Eclipse to IntelliJ and there is something which I couldn't find yet nor google:

How to get the autocomplete to replace the name of the function? In Eclipse, it would be the ctrl+enter functionality.

For example,

userController.setAmount();

suppose I would like not to call the setAmount() but a setDefaultPassword(), I place my caret after the set then ctrl+space to autocomplete, the setDefaultPassword() shows up but if I press enter, it won't replace Amount() and I'll end up with

userController.setDefaultPassword();Amount();

So obviously what I wanted is to replace the setAmount() by setDefaultPassword().


回答1:


Press Tab instead of Enter to select the item, and the identifier will be replaced. See also http://jetbrains.dzone.com/articles/top-20-code-completions-in-intellij-idea




回答2:


You can configure it in IntelliJ IDEA Settings under Keymap / Editor Actions / Choose Lookup Item Replace.




回答3:


Not a solution, but a workaround:

  1. place the cursor after set
  2. press ctrl + shift + cursor-right. So the characters after set are selected.
  3. press ctrl + blank
  4. select a proposal and press enter


来源:https://stackoverflow.com/questions/30640224/intellij-autocomplete-to-replace-the-function-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!