Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Eclipse Indentation problem with Object property

Ok, I have a problem with eclipse/javascript. The identation inside of an object property is 8 spaces and it pisses me off. I want it to be 4 spaces. What do I need to change in order to fix that? I want eclipse to format it like "b".

var a = {
        t: 'Hi'
};

var b = {
    t: 'Hi'
};

Thanks in advance.

like image 561
SBSTP Avatar asked Jun 24 '11 19:06

SBSTP


2 Answers

Eclipse Indigo (for J2EE)

Window -> Preferences -> JavaScript -> Code Style -> Formatter

then Edit...

Line Wrapping -> Expressions -> Object initializers -> Indentation policy: Indent by one

screenshot for configuration

like image 159
Wit Avatar answered Oct 22 '22 17:10

Wit


I have the same problem (also for Array).

The only thing that works for me is to disable the Smart Insert Mode (CTRL + Shift + Insert) to indent the first property, then if you enable it again it should be working properly.

like image 30
customcommander Avatar answered Oct 22 '22 18:10

customcommander