Sublime Forum

Auto-indent from HTML/PHP on OSX not working

#1

I recently switched platforms to OS X and downloaded Sublime (3114) having been a long time user on Windows.

It seems indenting in both .html and .php files seems to be broken. I’ve checked that “auto_indent”: true is set in Settings - Default and have even tried adding it to Settings - User and the syntax specific settings for both PHP and HTML but to no avail.

0 Likes

#2

can you define broken please?

There were some fixes to PHP embedding in HTML after build 3114, so it might be worth trying build 3120, to see if that fixes your problem.

0 Likes

#3

Take for example the following code… When on the Windows version I write < div > and hit enter, sublime automatically indents to the following line…

Some Title

However on OS X it is not indenting, it just writes like this…

Some Title

Additionally it doesn’t “unindent” when closing tags… Take for example I’ve written the following code and want to close my < /ul > tag… On windows immediately after writing < /ul > Sublime will recognise it’s a closed tag and unindent it like so…


  • Something

However on OSX this is also missing and the end result is this…


  • Something

This behaviour happens in both PHP and HTML files/syntaxes. Interestingly enough, indentation works just perfectly if I manually set the syntax to XML for example so I can only assume this is some sort of bug with HTML/PHP syntaxes and not something in the settings that I’ve unknowlingy messed up. For the record I’ve tried deleted Sublime and reinstalling but the result is the same.

0 Likes

#4

Not sure how you had it working previously in Windows, but basically the HTML syntax metadata is set to not do automatic indentation as you type, as I discovered here: https://github.com/guillermooo/sublime-undocs/issues/217#issuecomment-231712504 (see also ST3 Bug: Indenting moves in HTML)

the fix is to override the metadata file (Miscellaneous.tmPreferences) in the HTML package and change batchDecreaseIndentPattern to decreaseIndentPattern and batchIncreaseIndentPattern to increaseIndentPattern, either merging or removing the original decreaseIndentPattern and increaseIndentPattern rules so that there are no duplicate keys.

0 Likes

Auto-Indent HTML when press enter
Enable Auto indent in editor?