Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Eclipse equivalent of IntelliJ "Live templates"?

I mean stuff like typing "iter" and getting a "for" loop with a choice of what variable to iterate on , typing "soutv" to generate a "System.out.println" with the "variable=" already in ...

Thanks !

like image 229
akapulko2020 Avatar asked Oct 26 '10 09:10

akapulko2020


People also ask

What is live template IntelliJ?

Use live templates to insert common constructs into your code, such as loops, conditions, various declarations, or print statements. To expand a code snippet, type the corresponding template abbreviation and press Tab . Keep pressing Tab to jump from one variable in the template to the next one.


2 Answers

It is called Templates and it's found under,

Window → Preferences → Java → Editor → Templates

enter image description here

The "soutv" template does not exist ("sysout" does, and it's similar), but it's easy to add. I used this pattern:

System.out.println("variable=" + ${cursor}${});
like image 185
aioobe Avatar answered Oct 05 '22 19:10

aioobe


For 'soutv' particularly, I found the following pattern worked well in Eclipse:

System.out.println("${var} = ${cursor}" + ${var});

As others have mentioned, you can add this template by navigating to Window > Preferences > Java > Editor > Templates and clicking New.

The equivalent of 'iter' seems to be 'for' in Eclipse.

like image 39
Katie J. Ots Avatar answered Oct 05 '22 19:10

Katie J. Ots