简体   繁体   中英

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.

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

System.out.println();

To do that:

  • Select Window > Preferences > Java > Editor > Templates .
  • Scroll down the list of existing templates and select the one named sysout .
  • Click the Edit... button.
  • Change the Name field from sysout to sout , and click OK .
  • You will be invited to either replace sysout with sout , or add sout as a new template. 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

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:

匹配

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.

While editing in Eclipse it is not possible to have any action triggered simply by pressing the Enter key. 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.

If you could generate System.out.println(); just by typing sout and pressing Enter you wouldn't be able to create a line containing only sout .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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