Set code indent to space indent in eclipse

the Google Java programming style specification recommends that blocks be indented to two Spaces, while Eclipse defaults to using tabs (\t) to indent blocks, and here’s how you can change the indentation of code in Eclipse:

  1. open Eclipse;
  2. Window -> Preferences -> Java -> Code Style -> The Formatter.
  3. on the right click ‘New…’ “Initialize Settings with the following Profile”. Just select “Eclipse [Builin]” and click OK.
  4. click on “Edit…” Button;
  5. either choose “Spaces only” or “Tab policy” in “General Settings” on the “Indentation” Tab, and enter “2” as the value of “Indentation size”;
  6. click OK.

thus, holding down the Tab key while writing code in the Eclipse code editing area indents the code with two Spaces.

Read More: