HTML custom snippets not working in Visual Studio 2022 professional

Doug 0 Reputation points
2024-08-04T15:30:45.4033333+00:00

I've created some custom HTML snippets - copied right from MSDN tutorials. When on a .cshtml page I can find the snippet (it shows up when typing) but tab-tab doesn't do anything. The standard HTML snippets work just fine like a, audio, etc. No errors in the console. Please advise!

Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 34,686 Reputation points Microsoft External Staff
    2024-08-05T07:08:17.0566667+00:00

    Hello @Doug,

    Welcome to Microsoft Q&A forum.

    Try to use legacy Razor editor(Tools > Options > Text Editor > HTML > Advanced > Razor > Use legacy Razor editor for ASP.NET Core(requires restart) > set this option to True > restart VS) and test again.

    User's image

    I can reproduce this issue on my side with VS 2022. I see that the same/similar issue was reported before, see this ticket:

    Get snippets working in Razor

    and this ticket:

    Snippets don’t work in Razor Editor

    The first ticket is not closed, some features of the Razor Editor are still improving. Please either use the legacy Razor Editor currently, or kindly follow the ticket/submit a new ticket(GitHub - dotnet/razor).

    BTW, following is a screenshot which I used the legacy Razor Editor to test(the Square Root is a simple custom code snippet that mentioned in this document: Walkthrough: Create a code snippet in Visual Studio).

    User's image

    User's image

    Thanks for your understanding, have a nice day :)

    Sincerely,

    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.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.