How do you determine which formatter is being used for VS Code?

前端 未结 2 1264
北恋
北恋 2020-12-01 07:11

If you have multiple extensions installed how do you determine which formatter is running on your document?

For instance I have a couple of HTML extensions that may

相关标签:
2条回答
  • 2020-12-01 07:58

    Starting with the 1.33 release (March 2019), attempting to format a file for which there are multiple formatters registered results in a popup like this:

    Note that the notification is "silent" if formatting happened implicitly via "format on save" or "format on paste", meaning that you need to click the bell in the lower right for it to show up:

    The Configure... menu then lists all the formatters available for the current language. One of them can be selected as a default formatter for Format Document and Format Selection:

    Picking for instance "Prettier" here results in this being added to the global settings.json:

    "[html]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    }
    

    There are also two new commands for formatting a file with a specific formatter, Format Document With... and Format Selection With.... This can be useful for formatting a specific file with a formatter that's not set as the default formatter. The former is also available from the context menu:

    0 讨论(0)
  • 2020-12-01 08:01

    In addition to the answer given by Gama11 You can got to settings.json on below given path

    C:\Users\sameer\AppData\Roaming\Code\User\settings.json
    

    Note: your Users directory may differ

    As you can see I am using "prettier" formatter for my html files,

    Formatter configured for HTML files in settings.json

    also you can find the formatter been used for other extensions as well, if configured.

    0 讨论(0)
提交回复
热议问题