How to format code in Visual Studio Code on Windows

后端 未结 6 1353
臣服心动
臣服心动 2021-01-03 18:38

How can I format code in Visual Studio Code in the last update on Windows.

I tried Ctrl+ K, Ctrl + D doe

6条回答
  •  我在风中等你
    2021-01-03 19:02

    If it's for JavaScript, JSON, CSS, Sass, and HTML, there no better way than the Beautify extension. It is simple and very useful!

    Once installed the way you do it are described here with good illustrations (to avoid content duplication): How can I format PHP files with HTML markup in Visual Studio Code?

    For others languages, you add the appropriate extensions and you can set keybinding (you need to get the appropriate command to execute, and add the keybinding to keybindings.json). I have explained that in the link above. Always read well the documentation of the extensions. There you can find all the possible configurations and so.

    For specific languages you can search via Visual Studio Code in the extension marketplace. Enter just Beautify and you will see all the different Beautify extensions for the different languages. Also you can use formatting format formatter keywords, like PHP formatting and so.

    Also, you can use the integrated formatting tool of Visual Studio Code. Mostly by clicking right and selecting formatting document, you can also format just a selection.

    Here is the shortcut for formatting the whole document:

    • On Windows: Alt + Shift + F
    • On Mac: Shift + Option + F
    • On Ubuntu: Ctrl + Shift + I

提交回复
热议问题