In NetBeans, Tools | Editor | 'Code Templates' tab can be used to create new code templates. This entry details how to import code templates defined in NetBeans 6.0 editor into NetBeans 6.1. Even though the details are specific to these two versions, the concept should apply to any NetBeans version.

When NetBeans is first started, the user is presented with an option to import settings from previous versions, which would also import the code templates. The following information applies to manually importing the templates from 6.0 to 6.1.

NetBeans stores the user defined code templates in the <userdir>/config/Editors/text directory. There are separate directories for each language (like x-java , x-jsp etc). Each directory has a file called CodeTemplates/org-netbeans-modules-editor-settings-CustomCodeTemplates.xml which stores the custom code templates. (You may find some custom code templates like jaxbu that you did not define; that is fine: the ide itself creates some custom code templates...)  Since the templates are stored in a plain xml file, manually copy any (or all) templates defined by you from one version's CustomCodeTemplates.xml file to another version and restart the ide. You should now be able to see the copied templates in Tools | Options dialog.

Note:

  1. The CustomCodeTemplates.xml file uses a DTD file. NetBeans 6.1's CustomCodeTemplates.xml  file has the following DOCTYPE declaration: <!DOCTYPE codetemplates PUBLIC "-//NetBeans//DTD Editor Code Templates settings 1.0//EN" "http://www.netbeans.org/dtds/EditorCodeTemplates-1_0.dtd">. If two different versions of NetBeans use different dtds, the above method may not work in cases where the definition doesn't follow the dtd.
  2. Make a backup of CustomCodeTemplates.xml before modifying it. Check the templates immediately in the ide after modification. If the ide exhibits any strange behaviour, revert back to the backup file.


Comments:

testing your comment module

Posted by poiuy on July 24, 2008 at 08:31 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

This blog copyright 2008 by radhika