How do i format or beautify code in Visual Studio code?

I have just started using Visual Studio code, but i am not able to format code in it, I have tried ctrl k+ Ctrl d but it doesn't work, any helpful link for it?

Asked by:- jaya
: 10307 At:- 9/22/2017 4:36:23 PM
visual-studio-code code-formatting code-beautify php c#

2 Answers
profileImage Answered by:- Sam

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" }
At:- 9/23/2017 8:18:46 AM
thanks 0
By : jaya - at :- 10/4/2017 11:20:57 AM

profileImage Answered by:- neena

Visual Studio code, formatting is available for these languages:

  • xml (removed)
  • html
  • json
  • javascript
  • typescript
  • C#
  • php

Check this source for more details

At:- 9/25/2017 12:30:30 PM

Login/Register to answer
Register directly by posting answer/details

Full Name *

Email *

By posting your answer you agree on privacy policy & terms of use