Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to format HTML in a PHP file in Visual Studio Code [duplicate]

Tags:

I tried:

  • ALT + SHIFT + F
  • CTRL + K, CTRL + D
  • CTRL + K, CTRL + F

Also when I search for format via CTRL + SHIFT + P, there are no search results.

like image 441
progonkpa Avatar asked Dec 26 '16 09:12

progonkpa


Video Answer


2 Answers

On Windows, code formatting is available in VSCode through the shortcut Shift + Alt + F.

On Mac, it is available through the shortcut Shift + Option + F.

On Ubuntu, it's Ctrl + Shift + i.

Note: in the bottom right of the screen, it will show the text file form. Maybe plain text, PHP, HTML etc. If you click this you can switch the format of the file before issuing the above shortcuts.

like image 112
BUDNET CBE Avatar answered Sep 19 '22 14:09

BUDNET CBE


The problem is that Visual Studio Code won't format HTML if the file has a PHP extension (index.php). I'm going to post a new question that includes this information.

like image 28
progonkpa Avatar answered Sep 19 '22 14:09

progonkpa