How do i format or beautify code in Visual Studio code?;-If You have just started using Visual Studio code, but not able to format code in it, You have tried ctrl k+ Ctrl d but it doesn’t work, any helpful link for it?
format or beautify code in Visual Studio code
Formatting Code in Visual Studio can be done using the Keyboard shortcuts as below
- On Windows Shift + Alt + F
- On Mac Shift + Option + F
- On Ubuntu Ctrl + Shift + I
you can also find these as well as other shortcuts, through the search functionality provided in the editor with Ctrl +Shift+ P (or Command + Shift + P on Mac), and then search for format document.
For Php developer, if you are working on php you should download php extension format code.
Press F1
and type : ext install PHP Code Format
.
Then Shift + Alt + F
will work
You can add a keybinding in Preferences –> Keyboard shortcuts.
{ "key": "cmd+k cmd+d", "command": "editor.action.formatDocument" }
Or Visual Studio like:
{ "key": "ctrl+k ctrl+d", "command": "editor.action.formatDocument" }