Removing code background for C# razor syntax not working

Douglass, Harry W 20 Reputation points
2024-02-01T03:50:16.47+00:00

I've read Mika Dumont's blog on how this feature was added in VS 17.0.2 which states " A major difference in this area is the removal of the code background highlight that was present in previous versions. This highlight made selections difficult to distinguish and added visual clutter for many developers." User's image

However, I have yet to figure out how to get this working without removing the time-saving feature of typing the HTML element letter and then tab to write the HTML like p + [tab] -> <p></p> I may be missing how to do this, but as of my latest VS Enterprise 17.8.6, I still cannot get this to work. User's image

Here are my settings: User's image

User's image

User's image

Can anyone tell me the secret sauce here on how to do what Mika is telling us IS possible??

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

Accepted answer
  1. Tianyu Sun-MSFT 29,451 Reputation points Microsoft Vendor
    2024-02-01T07:57:25.1633333+00:00

    Hello @Douglass, Harry W,

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

    The feature you mentioned => "p+[tab] => <p></p>" should be a simple snippet.

    Different from the legacy Razor editor, the snippets related support is not currently available in the new Razor editor in Visual Studio 2022, as this blog says:

    Below is a list of known limitations that we are working to address: Snippets support (expansion with Tab) …

    So, to remove code background => use the new Razor editor. To use the simple snippet(Tab) like before => use the legacy Razor editor.

    It’s currently not possible to make both removing the code background and simple snippets(Tab) work.

    Some clues:

    1. Snippets don’t work in Razor Editor

    These will be in 17.9 Preview 1. See #9327 for details on any limitations that still exist

    1. Tested in 17.9.0 Preview 5.0, the "p+[tab] => <p></p>" still didn’t work, but "div+[tab]=><div></div>" worked.
    2. I may suggest you also report this feedback on GitHub/Razor.

    Thanks for your understanding and thanks for helping us make Visual Studio better.

    Have a great day.

    Best 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.


0 additional answers

Sort by: Most helpful