Reformat code does not reflect my code style config for tab indent

I have searched a number of times and have not come up with any answers. My problem is that I open the code style, select general, then select project. The default settings are 4, 4, 8 respectively. So I change them to 2, 2, 4, as well as change the defaults for HTML and Ruby as well. When I return to my file and click on reformat code for this file, nothing happens. But if I start a new line and click tab, it does only tab 2 spaces. Once I reformat my code again, if reverts back to 4 spaces.

How can I use the reformat to reflect the new 2, 2, 4 indent scheme?

I am currently working on a Ruby on Rails (using ERB files) project with another dev, who is using Sublime Text, and due to VCS issue, we need the spaces to be 2. I'd rather not have to discard Intellij for what seems to be a simple issue.

Comment actions Permalink

deglau wrote:

When I return to my file and click on reformat code for this file, nothing happens.

What file type is this happening in? You mention changing the values for HTML and Ruby, did you also change them for Java (if that is where you are having the issue)?

Changing these works fine for me.When I reformat my code, it changes to 2,2,4.

Also, what version of IntelliJ IDEA are you using?

Comment actions Permalink

Hi Mark,

I'm trying this with ERB files, although it doesn't seem to work in both .html and .rb files either. I don't develop in Java currently and I have not tested it in that file type.

I am currently using 13.1 and I remember having the same issue in 12 as well.

I've had to since switch to Sublime because of this issue for this particluar project which is just frustrating since I need to learn new shortcuts, etc.

Comment actions Permalink

I see in file types (in IDE Settings) that *.erb files are mapped as "RHTML" files. But the code styles settings do not have a specific definition for "RHTML" files.It looks like the XML settings are used for RHTML files. When I modified the settings for XML, the indenting changed... with one exception... I did notice in the small sample file I was using, that the XML setting changes did not affect one section, but a modification to the "Velocity" indent did. (I've never worked in Ruby, but it looks like the section is for a velocity template: <% @list_of_langauges.each do |item| %>).

You may want to open a feature request ( asking that RHTML style configuration be broken out to a dedicated setting (like it is for JSP and JSPX).

Comment actions Permalink

Thanks Mark,

That did seem to do the trick, but I think I'll put in a feature request anyway to help others.


Please sign in to leave a comment.