Setting up Eclipse

From Knowitall
Jump to: navigation, search

In general, the two big concerns are:

  • Spaces instead of tabs for indenting
  • Compatibility with Unix in terms of newline characters.

Note that Ctrl-Shift-F will reformat the open file, and to redo line delimiters you can go to "File -> Convert line delimiters to -> Unix". Also note that all the preferences below must be reset for each Eclipse Workspace.


For General Text Editing

  1. Go to "Window -> Preferences" to open up the Preferences window.
  2. Navigate to "General -> Workspace".
  3. Under "Text file encoding", click on "Other" and select "UTF-8"; under "New text file line delimiter", click "Other" and select "Unix". This will make Eclipse source files Unix-compatible.
  4. Navigate to "General -> Editors -> Text Editors".
  5. Check "Insert spaces for tabs" and set "Displayed tab width" to 4.

Optional but recommended step: check "Show whitespace characters". You can choose which characters to display, as well as their opacity, by clicking on "whitespace characters" (should be highlighted). You should see no carriage returns and no tab characters.


For Java

  1. Go to "Window -> Preferences" to open up the Preferences window.
  2. Navigate to "Java -> Code Style -> Formatter".
  3. Create a new profile.
  4. Click "Edit".
  5. Under the "Indentation" tab, make sure that the "Tab Policy" is "Spaces only" and that "Indentation size"/"Tab size" are set to 4.


For Scala

  1. Go to "Window -> Preferences" to open up the Preferences window.
  2. Navigate to "Scala -> Formatter".
  3. Under the "Indentation & Alignment" tab, set "Spaces to indent" to 2 and make sure "Indent using tabs" is NOT checked.
  4. Navigate to "Scala -> Organize Imports".
  5. Click "collapse into single import statement".