简体   繁体   English

Eclipse 创建自己的 system.out.println 快捷方式

[英]Eclipse Create your own system.out.println shortcut

如何更改键盘快捷键从系统输出+控制空间月食SOUT +进入像崇高。

How can I change the keyboard shortcut in eclipse from sysout + control space to sout + enter like in sublime.如何将eclipse中的键盘快捷键从sysout + control space更改为sout + enter,就像在sublime中一样。

The short answer is you can't.简短的回答是你不能。 But you can modify an existing template, or add a new template, to create a shortcut of sout that will generate但是你可以修改一个现有的模板,或者添加一个新的模板,来创建一个sout的快捷方式,它会生成

System.out.println();

To do that:要做到这一点:

  • Select Window > Preferences > Java > Editor > Templates .选择窗口 > 首选项 > Java > 编辑器 > 模板
  • Scroll down the list of existing templates and select the one named sysout .向下滚动现有模板列表并选择名为sysout 的模板。
  • Click the Edit... button.单击编辑...按钮。
  • Change the Name field from sysout to sout , and click OK .Name字段从sysout更改为sout ,然后单击OK
  • You will be invited to either replace sysout with sout , or add sout as a new template.您将被邀请将sysout替换为sout ,或者将sout添加为新模板。 Pick whichever option is appropriate.选择合适的选项。

That's all there is to it.这里的所有都是它的。 In the editor you can now type sout and press Ctl + Space to generate在编辑器中,您现在可以输入sout并按Ctl + Space生成

System.out.println();

However, there is no real need to do any of that because when you press Ctl + Space after typing sout the template sysout is offered as the first possible match:但是,实际上没有必要执行任何操作,因为在键入sout后按Ctl + Space 时,模板sysout将作为第一个可能的匹配项提供:

匹配

So without making any changes to Eclipse you can type sout and press Ctl + Space , then Enter (to select the first entry in the dropdown list) to almost achieve what you want.因此,无需对 Eclipse 进行任何更改,您可以键入sout并按Ctl + Space ,然后按 Enter (以选择下拉列表中的第一个条目)几乎可以实现您想要的。

While editing in Eclipse it is not possible to have any action triggered simply by pressing the Enter key.在 Eclipse 中进行编辑时,不可能仅通过按Enter键来触发任何操作。 That's because the Enter key already has a well defined function: to move to the next line, taking any text with it that is to the right of the cursor.那是因为Enter键已经有一个明确定义的功能:移动到下一行,并带有光标右侧的任何文本。

If you could generate System.out.println();如果你可以生成System.out.println(); just by typing sout and pressing Enter you wouldn't be able to create a line containing only sout .仅通过键入sout并按Enter 键,您将无法创建仅包含sout的行。

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

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