0

I know if I write

sysout in java code editor and type ctrl+space then sysout replaces to System.out.println();

and other template: for example for:

for (${iteratorType:newType(java.util.Iterator)} ${iterator} = ${collection}.iterator(); ${iterator}.hasNext(); ) {
    ${type:elemType(collection)} ${name:newName(type)} = (${type}) ${iterator}.next();
    ${cursor}
}

How to use this template?

What I must to write and what I will see?

enter image description here

update:

enter image description here

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710

2 Answers2

1

You can check existing templates and write new templates in:

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

Check this question about this: Question.

Community
  • 1
  • 1
fjtorres
  • 266
  • 6
  • 13
1

The name of the template is what you have to type before pressing ctrl+space to use the macro. As you see, there are more than one macro with the name for so it will never be inserted automatically but you will have to choose between them. Further, since the name is equal to a keyword, just inserting the keyword will also be offered as an option. It depends on your configuration whether macros are offered immediately in the list of choices or if you have to press ctrl+space multiple times to toggle between code completion and macro expansion.

Holger
  • 285,553
  • 42
  • 434
  • 765