48

Say I type "sout", the intellisense should expand it to "System.out.println()". Is there a way to adding such templates?

Bhushan
  • 18,329
  • 31
  • 104
  • 137
Artin
  • 745
  • 1
  • 7
  • 14

7 Answers7

68

The feature is called "code templates" in Eclipse. You can add templates with:

Window->Preferences->Java->Editor->Templates.

Two good articles:

Also, this SO question:

System.out.println() is already mapped to sysout, so you may save time by learning a few of the existing templates first.

muneeb_ahmed
  • 364
  • 5
  • 16
Michael Brewer-Davis
  • 14,018
  • 5
  • 37
  • 49
29

Type "Sysout" and then Ctrl+Space. It expands to

System.out.println();
Saurabh Gokhale
  • 53,625
  • 36
  • 139
  • 164
14

Type syso and ctrl + space for System.out.println()

Bala R
  • 107,317
  • 23
  • 199
  • 210
7

type "syso" and then press ctrl + space

OR

type "sysout" and then press ctrl + space

Jaykishan
  • 1,409
  • 1
  • 15
  • 26
4

This is one more option: go to Windows > Preference > Java > Editor > Content Assit. Look in "Auto Activation" zone, sure that "Enable auto activation" is checked and add more charactor (like "abcd....yz, default is ".") to auto show content assist menu as your typing.

TRaveL
  • 41
  • 1
1

I've been Eclipse-free for over a year now, but I believe Eclipse calls these "Templates". Look in your settings for them. You invoke a template by typing its abbreviation and pressing the normal code completion hotkey (ctrl+space by default) or using the Tab key. The standard eclipse shortcut for System.out.println() is "sysout", so "sysout" would do what you want.

Here's another stackoverflow question that has some more details about it: How to use the "sysout" snippet in Eclipse with selected text?

Community
  • 1
  • 1
Ryan Stewart
  • 126,015
  • 21
  • 180
  • 199
0

Step 1 -> Top apple icon -> System preference -> keyboard -> Shortcut>spotlight -> uncheck. Step 2 ->Eclipse -> General -> keys -> search -> content Assist -> Binding (cmd button + space) -> Apply&close.

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/30616785) – Procrastinator Dec 18 '21 at 09:24