As I slowly crawl in my transition from .net to Java, I find more and more interesting things about the eclipse IDE. I recently stumbled upon its templates and I’m loving it. Which brings me to a question: can I call a template from within a template? Of course it would be merely a copy and paste matter, but I’m wondering if it can be done.
Share
Yes, actually, you can and there is an example right in the default set.
If you go to your Preferences -> Java -> Code Style -> Code Templates, you can Export All of the provided Java templates. In there you will see the following File template (formatted for readability):
and a bit further down, the New Type which makes use of that File template:
So, if you’d like to make a template use another, the basic form is to refer to the id of your sub-template with the dollar sign prefix. For example: