2

I just switched back from PDT to PHPEclipse (Because PDT is too unstable for my taste) but now I have the problem that I can't find out how to tell PHPEclipse to indent PHP code with spaces instead of tabs. I have enabled the usage of spaces in the following preference locations:

PHPEclipse/PHP/Formatter/ (Unchecked "Indentation is represented by a tab")
General/Editors/Text Editors/ (Checked "Insert spaces for tabs")

*.php Files are only associated with the PHPEclipse editor and the standard text editor. The PHPEclipse preferences page says "Some general preferences now live on the Text Editors pages" so it sounds like PHPEclipse should use the general text editor preferences. But it just doesn't work. PHPEclipse always uses tabs instead of spaces.

Any hints how I can get it to use spaces?

kayahr
  • 20,913
  • 29
  • 99
  • 147

4 Answers4

7

just added PHPEclipse to my Eclipse, seems that the following should help you:

Window > Preferences > PHPEclipse > PHP > Typing*

"Typing" is name of tab. There is setting "Insert spaces for tab (see Code Formatter preference page", check it and you will get spaces instead of tabs ;)

Maxym
  • 11,836
  • 3
  • 44
  • 48
2

I tried ok for eclipse-php 3.0.2:

1. go to "window > preferences > code style > formatter ";
2. change tab policy from "tabs" to "spaces"; 
3. change indentation size as you need;
4. Apply - ok.
Till
  • 1,097
  • 13
  • 13
1

The following worked for me (PHP Symfony also installed).

My version of Eclipse: Eclipse SDK 4.2.2

Installed

  • PHP editor: PHP Development Tools (PDT) 3.1.
  • Symfony Feature: 1.0.85

Instructions

  1. go to "Window > preferences > PHP > Code Style > Formatter (PDT Tools)
  2. Switch the "Active profile" from Eclipse [built-in] to Symfony [built-in]

The Eclipse built-in profile had tab indents in the preview; whereas the Symfony built-in profile has 4 spaces for each indent.

  • (2019) I changed it from PSR-2 to PHP Conventions, which allowed me to have tabs instead of spaces, which is what I wanted. – Mark Jul 16 '19 at 16:29
1

I'm using eclipse 3.8.1. Following worked for me:

Windows > PHP > Code Style > Formatter
Set "Tab policy:" to "Spaces
  • Same for Eclipse 4.4 Luna. Too bad that PHP > Editor refers to "Note that some preferences may be set on the Text Editors preferences page", which also has Tab settings but which are ignored for PHP files. Also, searching for "php" does not even show the "Code Style" section, but does show that "Editor" section... – Arjan Sep 17 '14 at 08:58