Format code command for PHP/HTML in Visual Studio Code

To format code in Visual Studio Code, you can use the following steps:

  1. Select the text that you want to format, or press Ctrl+A to select all of the text in the current document.

  2. Press Shift+Alt+F to open the "Format Document" window.

  3. Select "PHP" or "HTML" from the dropdown menu, depending on the type of code you are formatting.

  4. Click the "Format" button to apply the formatting to the selected text.

Watch a course Learn object oriented PHP

Alternatively, you can also use the keyboard shortcut Ctrl+Shift+I to automatically format the code in the current document. This shortcut will use the default formatting settings for the language of the document, so you don't need to specify a language like you do with the "Format Document" window.