/
Code and XML Formatting in Eclipse

Code and XML Formatting in Eclipse

Overview

This document describes how to configure code formatting in eclipse. Note, each workspace you use must be configured independently to reuse these settings.

Character Encoding and Line Termination Settings

 Under Window->Preferences->General->Workspace you can configure these settings.  Use the following:

  • Character encoding - UTF-8
  • Line Termination  - Unix (\n)

Java files

Java file formatting is configured via Window->Preferences, Java->Code Style->Formatter. The following attachment can be loaded by using the "Import" feature of the formatter.

Use Java->JAutodoc to configure the jautodoc templates. The following attachment can be loaded by using the "Import All" feature of the configuration screen

To complete the JAutoDoc configuration, open window preferences and go to Java -> Code Style -> Code Templates. Expand "comments" and choose "Overriding methods" and click the "Edit" button.  Replace the template with the following text:

/* see superclass */

Javascript Files

Javascript formatting is configured via Window->Preferences, Javascript->Code Style->Formatter.  The following attachment can be loaded by using the "Import" feature of the formatter.

XML Files

HTML file formatting is configured via Window->Preferences, XML->XML Files->Editor. The following shows a screenshot of how XML formatting should be configured.

 

HTML Files

HTML file formatting is configured via Window->Preferences, Web->HTML Files->Editor. The following attachment shows a screenshot of how HTML formatting should be configured.  Additionally, in the "inline elements" list, remove "a" and "span" and "td" as it makes for better formatting.

 

Other files

If formatters for other files are needed, more details should be added to this document.

 

Related content