Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highlighting kills my Razor syntax in Visual Studio 2010

I'm using Expression theme in Visual Studio 2010 Ultimate on Windows 7 operating system. (Note: Actually, I'm not sure this problem occurs because of the dark theme) A few days ago, I decided to learn ASP.NET MVC 4 and tried to create a small web application. In Visual Studio, I followed this instruction and created a new asp.net mvc 4 web application: File->New->Project->ASP.NET MVC 4 Web Application.

Everything was perfect. But when I opened the Login.cshtml file, I couldn't even see the razor syntax (expressions which started @) because of highlighting. Take a look:

enter image description here

Even if I select all the text with CTRL + A in Visual Studio, I barely see the syntax.

enter image description here

Because of that, I can't even start to learn asp.net mvc. I started to look for a solution for this situation on the internet, but I couldn't find any useful answer. In Visual Studio, I looked the Tools->Option->Font and Colors option, but I couldn't find anything for this either. This problem shows only when I'm working in a View (for the Razor). There is no highlighting problem in Model, Controller or any other code files.

User ray247 asked a question close enough to my question called Where can I change the Asp.net MVC 3 Razor syntax hightlighting in VS10? but I still can't find a solution. I don't want to stop using my dark theme. It's really good for my eyes.

like image 320
Soner Gönül Avatar asked Nov 26 '12 12:11

Soner Gönül


People also ask

What is razor in Visual Studio?

What is Razor? Razor is a markup syntax that lets you embed server-based code (Visual Basic and C#) into web pages.

What is Razor syntax in C#?

Razor supports C# and uses the @ symbol to transition from HTML to C#. Razor evaluates C# expressions and renders them in the HTML output. When an @ symbol is followed by a Razor reserved keyword, it transitions into Razor-specific markup.

What is razor in MVC What are the main Razor syntax rules?

Razor is a simple programming syntax for embedding server code in web pages. Razor syntax is based on the ASP.NET framework, the part of the Microsoft.NET Framework that's specifically designed for creating web applications.

What is syntax highlighting in Visual Studio Code?

Syntax highlighting determines the color and style of source code displayed in the Visual Studio Code editor. It is responsible for colorizing keywords like if or for in JavaScript differently than strings and comments and variable names. There are two components to syntax highlighting: Tokenization: Breaking text into a list of tokens

How do I Turn on the New Razor editor in Visual Studio?

Go to Tools > Options > Environment > Preview Features and select the Enable experimental Razor editor option: When you go to turn on the new Razor editor you may find that it’s already on. Starting with Visual Studio 16.9 Preview 3 we are slowly rolling out the new Razor editor to different groups of users.

How to add IntelliSense and syntax coloring to Razor pages?

Locate again the ASP.NET and Web Development package and check it, then click the Modify button to install it from scratch. Once done, launch Visual Studio 2017: if everything went well, your Razor pages will now have proper Intellisense and syntax coloring. That’s it!

What does aspnetmvc3setup install for Visual Studio 2010 to support Razor syntax?

Both the options run AspNetMVC3Setup.exe and it installs Visual Studio 2010 support for Razor syntax in addition to other components bundled in the exe. What does ASPnetMVC3Setup.exe install for Visual Studio to support the syntax? The ASP.NET MVC 3 installer includes the following components. Components in bold add the support.


1 Answers

You should be able to change the text background for Razor code by:

  1. Opening Visual Studio Options (Under Tools -> Options),
  2. Selecting "Fonts and Colors" (Under Environment in the treeview at left)
  3. Changing the dropdown box at top to "Text Editor" (if that isn't the value already),
  4. Choosing "Razor Code" from the "Display Items" listbox, and
  5. Changing the background color to your liking and clicking "OK" to apply the change.

There's also an "HTML Server-Side Script" setting that controls the background color of the Razor code delimiters (the @ expression and similar expressions that mark the beginnings of code blocks.)

HTH,
Clay

like image 118
Clay Compton Avatar answered Oct 23 '22 15:10

Clay Compton