1

I have read many similar questions on SO, but none answer my problem.

I have a .php file with this content:

<?php something(); ?>

<div class="container">
                         <div class="row">
                             <div class="col">
Hello World!
</div>                             
            </div>
</div>

And I would like to reformat either the php or the html code, either globally or the selection.

I have tried all the Format document option, but it does not work.

Ctrl+Shift+p, Format document

If I change the extension for .html, then it works.

nowox
  • 25,978
  • 39
  • 143
  • 293
  • hey you might need to install https://github.com/Dickurt/vscode-php-formatter/wiki - give it a try! – Matthias Reumann Jul 14 '18 at 11:09
  • Possible duplicate of [VSCode Format code command for PHP/HTML](https://stackoverflow.com/questions/32236030/vscode-format-code-command-for-php-html) – jabacchetta Jul 14 '18 at 18:38
  • Yup, it looks like a duplicate, however, the linked question does not really give an answer to this one :( – nowox Jul 14 '18 at 18:43

1 Answers1

3

There are many extensions in the marketplace of VSCODE for formatting the code. Try one of them. I might even recommend Prettier ext. Try others as well you might one usefull

Krishanu
  • 552
  • 3
  • 21
  • Well, It worked on html for me Its your choice completely, the extension marketplace is full of options! – Krishanu Jul 19 '18 at 10:56