简体   繁体   English

IntelliJ Idea:用于像Eclipse中那样创建方法的代码完成

[英]IntelliJ Idea: code completion for creating method like in Eclipse

I am using Eclipse for about 5 years. 我正在使用Eclipse大约5年。 Now I'm begging with IntelliJ Idea 13. I can not get used to code completion :-( 现在,我乞求IntelliJ Idea13。我不能习惯于代码完成:-(

How can I create new public method? 如何创建新的公共方法?

In Eclipse i press: 在Eclipse中,我按:

pub CTRL+SPACE ENTER int CTRL+SPACE test ENTER

and get 并得到

public int test() {

}

how can I do it in Idea? 如何在Idea中完成?

在此处输入图片说明

如果此场景对您很重要,则可以使用IntelliJ的实时模板

You can add a 'Live Template' in IntelliJ. 您可以在IntelliJ中添加“实时模板”。 Go to Preferences -> Live Templates -> Select your language (if Java is not there, you can select Other), select the "+" symbol and add a new template. 转到首选项->实时模板->选择您的语言(如果Java不存在,则可以选择其他),选择“ +”符号并添加一个新模板。 eg Abbreviation = test, and put your method in the Template text. 例如,缩写=测试,然后将您的方法放在模板文本中。

IntelliJ will display a message 'No applicaable contexts yet'. IntelliJ将显示一条消息“尚无适用的上下文”。 Define' just below the box. 在框下方定义“”。 If you click on 'Define' you can select 'Java' in the list that shows up. 如果单击“定义”,则可以在显示的列表中选择“ Java”。

In your editor, type the template abbreviation and press the tab key. 在编辑器中,键入模板的缩写,然后按Tab键。

There are no built-in templates for that. 没有内置模板。 You can create your own, like other answers advise. 您可以自己创建,就像其他答案建议的那样。 But in general, just typing the method with autopopup completion seems to require almost the same number of key presses: 但总的来说,仅键入具有自动弹出完成功能的方法似乎需要几乎相同的按键次数:

pub < autopopup appears with "public" selected, hit ENTER > int test( < CTRL+SHIFT+ENTER > pub <autopopup出现并选择了“ public”,然后按ENTER> int test(<CTRL + SHIFT + ENTER>

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

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