Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Most of the formatting conventions for this project center around the use of white space and the placement of brackets. Formatter settings for Eclipse and IntelliJ are covered first, followed by more detailed descriptions.

Eclipse and IntelliJ formatter settings

Eclipse

Set the file encoding to UTF-8

No Format
    Window > Preferences > General >
        Workspace > Text file encoding > Set explicitly to "UTF-8"
    Window > Preferences > General > 
        Workspace > New Text file line delimiter > Set explicitly to "Unix"

Set the editors to insert spaces instead of tabs

No Format
    Window > Preferences > General > 
        Editors > Text Editors > Check "Insert Spaces for tabs"

Import newline/brace/indentation formatter settings. This will create a new formatter profile which you should activate when working with project source files.

No Format
    Window > Preferences > Java > 
        Code Style > Formatter > Import > 
            Import etc/eclipseFormatterProfile.xml

Avoid using Eclipse Auto-formatting - "Ctrl + Shift + F" for entire file while changing a part of the file. Especially for an existing file as it makes it difficult to know the exact difference by comparing revisions.

IntelliJ

...

File

...

No Format
Select the Editor -> Code Style tab. Push the "Manage" button and then the "Import..." button
  Select either the Eclipse or the Intellij format
    Import the corresponding file from the etc directory

File encoding

Use UTF-8 file encoding and Unix line separators. Some source code files contain UTF-8 characters and will be damaged if you modify them with an editor that does not support UTF-8 encoding.

...

Code Block
    // CORRECT: A public class definition
    public class MyClass {
      ...
    }

    // WRONG:
    public class MyClass
    {
      ...
    }

    // WRONG:
    public class MyClass {
      ...
      }

    // CORRECT: A method definition
    void method(int j) {
      ...
    }
    
    // CORRECT: A do/while
    do {
      ...
    } while (...)

 

Eclipse and IntelliJ formatter settings

Eclipse

Set the file encoding to UTF-8

No Format
    Window > Preferences > General >
        Workspace > Text file encoding > Set explicitly to "UTF-8"
    Window > Preferences > General > 
        Workspace > New Text file line delimiter > Set explicitly to "Unix"

Set the editors to insert spaces instead of tabs

No Format
    Window > Preferences > General > 
        Editors > Text Editors > Check "Insert Spaces for tabs"

Import newline/brace/indentation formatter settings. This will create a new formatter profile which you should activate when working with project source files.

No Format
    Window > Preferences > Java > 
        Code Style > Formatter > Import > 
            Import etc/eclipseFormatterProfile.xml

Avoid using auto-formatting - "Ctrl + Shift + F" for an entire file while changing a part of the file. Especially for an existing file as it makes it difficult to know the exact difference by comparing revisions.


IntelliJ

Open the Settings dialog with File -> Settings...

No Format
Select the Editor -> Code Style tab. Push the "Manage" button and then the "Import..." button
  Select either the Eclipse or the Intellij format
    Import the corresponding file from the etc directory

 

Avoid using reformatting commands for an entire file while changing a part of the file. Especially for an existing file as it makes it difficult to know the exact difference by comparing revisions.