Behzad Pirvali
Behzad Pirvali

Reputation: 784

IntelliJ formatting HTML

I was not able to find a way to make IntelliJ format HTML code consistently through inserting new lines and indents.For example, this code:

<li class="nav"><a href="/about">
About</a></li>

Should be formatted to this:

<li class="nav">
    <a href="/about">About</a>
</li>

Or:

<li class="nav">
    <a href="/about">
        About
    </a>
</li>

When I try to re-format selected text or entire file, this segment is not changed!!!

I have already tried to play with Preferences > Language > HTML > Code Style, but no success!

Upvotes: 2

Views: 1349

Answers (2)

Bohuslav Burghardt
Bohuslav Burghardt

Reputation: 34846

This is related to Element inlining. When you look at the code style settings for HTML there is Inline elements selection. When you remove a tag from this selection and reformat your code, the code will be arranged the way you want it (i.e. a will not be kept on the same line as li).

enter image description here

Upvotes: 3

Tome Pejoski
Tome Pejoski

Reputation: 1582

Navigate again to navigate to Preferences > Language > HTML > Code Style and configure as:

enter image description here enter image description here

Then try to select the code and reformat.

Upvotes: 1

Related Questions