How to get Visual Studio 2022 to edit a YAML file that does not have a .yaml extension.

mgbrown 0 Reputation points
2024-03-22T15:19:31.61+00:00

I would like to be able to edit YAML files in Visual Studio 2022. If I open a file with a .yaml, though the editor experience isn't great it does do syntax highlighting. However my files do not have a .yaml extension. I tried adding the extension to Tools > Options > Text Editor > File Extensions and giving it the Common Language Editor Supporting TextMate Bundles editor, but I still don't get syntax highlighting. Any ideas how to do this?

Also is it possible to get it to validate against a json schema?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,607 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 27,271 Reputation points Microsoft Vendor
    2024-03-25T06:33:23.5333333+00:00

    Hello @mgbrown,

    Thank you for taking time to post this issue in Microsoft Q&A forum.

    Looks like Visual Studio 2022 fails to recognize the yaml code in the extensionless files, even you have selected Common Language Editor Supporting TextMate Bundles.

    Currently, there’s no other option in Visual Studio 2022 to map the extensionless files to direct yaml editor. A .yaml extension is necessary. I would suggest you kindly submit a feedback ticket on our Developer Community.

    Also is it possible to get it to validate against a json schema?

    Related features have been available since Visual Studio 2022 version 17.1, see this ticket: Support YAML schema validation and IntelliSense by schemas from schemastore.org (or custom schema).

    Kind Regards,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.