简体   繁体   English

Eclipse快捷方式自动填充有用类型的实例变量?

[英]Eclipse shortcut to autofill a usefull type of instance variable?

What is the Eclipse shortcut for getting an instance variable in this example? 在此示例中获取实例变量的Eclipse快捷方式是什么?

If I write 如果我写

new String("TestString");

now I would like to autofill an Instance type of 现在我想自动填充实例类型

String s =

How can I do this with Eclipse IDE to get this result: 如何使用Eclipse IDE执行此操作以获得此结果:

String s = new String("TestString");

With the cursor at the start of the line Ctrl + 1 should bring up a context menu with the option assign to new local variable, I think that is what you are looking for. 当光标位于行的开头时,Ctrl + 1应显示一个上下文菜单,其中包含分配给新局部变量的选项,我认为这就是你要找的东西。 PS new rather than New will compile much better ;-) PS new而不是New会编译得更好;-)

You can create your own "Templates", 您可以创建自己的“模板”,

On Eclipse open Window > Java > Editor > Templates, click the button New... 在Eclipse上打开Window> Java> Editor> Templates,单击New ...按钮

In your name put the thing you want to type to auto-complete, then put the code in pattern. 在你的名字中,将要输入的内容自动完成,然后将代码放入模式中。

But if you just need simple auto-completion, in general eclipse does that by default using CTRL+SPACE 但是如果你只需要简单的自动完成,通常eclipse默认使用CTRL + SPACE

If you need to complete your statement you can use SHIFT+ALT+L too (you can find it in Refactor > Extract Local Variable) 如果您需要完成语句,也可以使用SHIFT + ALT + L(您可以在Refactor> Extract Local Variable中找到它)

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

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