JDT provides several editor templates. You can also add your own via the Templates View. However, if you want to share the templates between your several workspaces or with others you can also create a plugin.
As a first step, define the following extension for the extension point org.eclipse.ui.editors.templates.
I have also shared a plugin with the above code on GitHub.
As a first step, define the following extension for the extension point org.eclipse.ui.editors.templates.
<extensionThe xml file just contains the template descriptors. For example, here is a template for printing the enclosing type and the enclosing method.
point="org.eclipse.ui.editors.templates">
<include
file="templates/default-templates.xml"
translations="$nl$/templates/default-templates.properties">
</include>
</extension>
<template name="debugout" description="%Templates.debugout" id="com.eclipse.jdt.ui.templates.debugout" context="java-statements" enabled="true" autoinsert="true">You can read about the available template variables in Eclipse help.
System.out.println("${enclosing_type}#${enclosing_method}(..)");${cursor}
</template>
I have also shared a plugin with the above code on GitHub.