Where can I change the Asp.net MVC 3 Razor syntax highlighting in VS10?
Asked Answered
P

3

23

I searched Tools > Options, but where in VS10 can I turn off or change the default highlighting for the new Razor view on the @nuggets in ASP.NET MVC 3?

Polycarp answered 14/1, 2011 at 21:23 Comment(3)
Why do you want to change it?Bigot
It is hard for my eyes for some reason, just personal issue.Polycarp
related Highlighting kill my Razor syntax in Visual Studio 2010Splendor
S
53

Razor only adds one entry to Fonts & Colors, "Razor Code". That controls the background color given to Razor Code nuggets. The rest of the colors are the same as the C#/VB colors. The "@" character itself and Razor keywords like "model" and "section" use the same color as the ASPX "<%" tag ("HTML Server-Side Script", thanks to another Andrew for digging up the specific entry).

If you'd rather we had separate entries for some of these, please email us and suggest that: [email protected]

Sanferd answered 14/1, 2011 at 23:20 Comment(9)
Slight clarification - the @ and other keywords were the HTML Server-Side Script entry under Fonts and Colors. I had a hard time finding it.Broiler
Edited and credited :). Thanks for closing the loop and posting a comment!Sanferd
This is exactly what I needed to fix a darker theme =) ... thanksCoach
Don't forget to restart VS after you have made the change.Ary
VS2013 appears to have change this from "Razor Code" to "HTML Server Code Block Background".Referential
In my VS 2013, after changing this 'HTML Server Code...', the razor file didn't re-highlight until I scrolled the relevant section out of view and back again, just a caveat in case it doesn't seem to work on yours either!Pantechnicon
Visual Studio's options were showing me a background colour that did not match the one actually used in the editor; that is, it was lying to me. This was confusing as the colour in the Options dialogue was the one I actually wanted to use. So I had to set it to a dummy colour, apply the change, then reset it to my intended colour.Giff
@Pantechnicon I have the opposite problem. The highlighting is lost when scrolling the window in VS2015.Ingemar
In Visual Studio 2019, it's also HTML Server-Side Script. What a non-intuitive name! >:-6Metaplasia
V
1

The syntax highlighting for razor is based on the c#/VB default highlighting. So you'll have to change those settings to see any changes in a cshtml file highlighting. Might be a good feature request...I don't know.

Vulcanite answered 14/1, 2011 at 22:58 Comment(0)
L
1

In Visual Studio 2015

Tools -> Options -> Environment -> Font and colors

The name of the property is HTML Razor Code Background Change the Item background to the color you like.

Lamellar answered 13/10, 2016 at 13:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.