VSCode: How do you autoformat on save?

后端 未结 3 1995
無奈伤痛
無奈伤痛 2021-02-18 15:01

In Visual Studio Code, how do you automatically format your source code when the file is saved?

3条回答
  •  一向
    一向 (楼主)
    2021-02-18 16:04

    Below are the steps to change the VS Code auto format on save settings:

    1. Use [Ctrl]+[Shift]+[p]
    2. Type "Preferences"
    3. Select "Preferences: Open User Settings"
    4. Search for "format"
    5. Change "Editor: Format On Save" or "Editor: Format On Paste".

    There are also Keyboard Shortcuts for formatting in VS Code. For instance, the default to format selected code should be [Ctrl]+K [Ctrl]+F (type both hotkeys in succession).

    Below are the steps to change the auto format hotkey settings:

    1. Use [Ctrl]+[Shift]+[p]
    2. Type "Keyboard"
    3. Select "Preferences: Open Keyboard Shortcuts"
    4. Search for "format"
    5. Change "Format Selection" or "Format Document".

提交回复
热议问题