PhpStorm not formatting HTML files

When I press Ctrl+Alt+L, html files do not get reformatted and instead I receive a message saying "No lines changed: content is already properly formatted".

below is a screenshot of the code after it has been 'formatted'

 

 

 

This only happens to HTML files, anything else (such as PHP, JS, CSS, Twig, etc) are fine.

Below is a screenshot of the settings I have in Code Style > HTML

6 comments

Hi there,

Why that <html> opening and closing tags having a green background? Is that a current element (cursor is there) or something else?

In any case: please post a screenshot of your "Settings/Preferences | Editor | Language Injections". It's possible you some have created some bad injection rule...

0

Hi, 

thanks for your reply, the <html> tags were selected as my cursor was there. Below are the requested screenshots of my language injections settings;

 

 

There are two injections for HTML in this list, the first one (php: "<html>") has the following place pattern:

+ and(not(phpLiteralExpression().withSuperParent(2, phpFunctionReference().withName(or(string().startsWith("strip_tags"), string().startsWith("preg_"))))), phpLiteralMatchesBrics(".*\\</?<anyname>( .*)?(/)?>.*"))

 

The second one (php: <<<HTML) has the following place pattern:

+ phpLiteralExpression("HTML")

 

I can't see anymore in that list where the language column contains 'HTML'.

Hope this helps.

0

Your Language Injections are fine (all entries are bundled, no custom ones).

1) Try unchecking "Keep line breaks" option (2nd original screenshot). Unlikely to help but still...

2) What file icon those files have? Maybe they are associated with some another file type?

3) Maybe it's one of the custom plugins? Or even bundled one (especially if they are related to HTML (e.g. Vue/Angular). Try disabling them and check it again after restarting IDE

4) Look for any related hints in idea.log file (Help | Show Log in XXX)

 

1

Hi Andriy,

Thank you for your reply, below is the answers to your points.

1) Unfortunatley this didn't work

2) Below is a screenshot of the file type icon, it is a page with 'H' in a green bar at the bottom;

3) I disabled every plugin I have in my PHPstorm and the styling did in fact change, instead of styling it properly though, it just removed all indentation. - I think we might be on to something here. I'm going to go through each plugin individually to see if I can find which one is affecting the styling.

0

Found the problem, it was with a plugin called 'Svelte', which i have personally never heard of so don't know how it was installed in the first place, but at least it's been found now - thank you Andriy

1

It's a 3rd party plugin, not sure which one you have got though: https://plugins.jetbrains.com/search?correctionAllowed=true&orderBy=&pr=phpstorm&search=Svelte

If it's a first one then it may be incompatible with latest IDE versions and it would be this ticket: https://github.com/dschulten/sveltejs-idea-plugin/issues/6  (sounds like your case exactly)

Try installing 2nd plugin if you need Svelte support.

0

Please sign in to leave a comment.