visual-studiovisual-studio-2022syntax-highlighting

syntax highlighting Visual Studio 2022 in .cshtml files not working


I am using Visual Studio 2022 on my working laptop and the syntax highlighting in .cshtml files does not work

Syntax not highlighted

which makes it hard to debug the code

HTML code usually is highlighted correctly

JS code is not higlighted at all

on my personal laptop same version of VS 17.7.7 the code is highlighted correctly. Issue with highlighting is only on my working laptop

What I tried

Has anyone experienced this ? I saw some posts about versions of VS 2015 and VS 2017 But unfortunately any of the fixes did not work for me


Solution

  • The <script> tag needs to be indented by one Tab for my VisualStudio to be considered as a JS code and apply some highlighting.

    I am not sure what the reason is but it works.

    Note: I have noticed that the problem occurs again once I have installed ReSharper even if I have set the highlighting to none

    Visual Studio Professional 2022 (64-bit)

    Version - 17.8.7

    ASP:NET and Web Tools - 17.8.358.6298

    enter image description here