Search code examples
htmlpycharmformatter

Why does PyCharm formatter append a new line in <script> and <style> tags whenever a HTML file is reformatted?


If a HTML document looks like :

<style>
h1 {text-align:center;}
</style>
.
.
.
.
.
<script>
var a;
</script>

then after formatting the HTML file by using either ( Code > Reformat File... ) or Ctrl+Alt+L , the HTML file looks like :

<style>
h1 {text-align:center;}
           <!-- New line got appended -->
</style>
.
.
.
.
.
<script>
var a;
             <!-- New line got appended -->
</script>

So how we can stop this appending of new line in <script> and <style> tags whenever the HTML file is reformatted in PyCharm ??


Solution

  • So the way to stop appending of new line in <script> and <style> tags whenever the HTML file is reformatted in PyCharm is to go to :

    File > Settings... > Editor > Code Style > HTML > Other > Keep white spaces inside:

    Then add the value ,script,style to the Keep white spaces inside:

    enter image description here