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

2

22

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.

Crispi answered 26/12, 2016 at 9:56 Comment(2)
#29973857Imp
code.visualstudio.com/Docs/languages/htmlImp
C
6

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.

Crispi answered 26/12, 2016 at 10:43 Comment(1)
In the bottom right of the screen, it will show PHP, if you click this, and select HTML, you can then format your text. Once formatted, switch back to PHP.Byblow
S
61

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.

Seldan answered 26/12, 2016 at 10:14 Comment(1)
This dont work...Penguin
C
6

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.

Crispi answered 26/12, 2016 at 10:43 Comment(1)
In the bottom right of the screen, it will show PHP, if you click this, and select HTML, you can then format your text. Once formatted, switch back to PHP.Byblow

© 2022 - 2024 — McMap. All rights reserved.