Getting HTML Colorization with Razor View Engine

Posted on 27 July 2010 and tagged with , , . Short link:

imageToday the Gu announced the first preview of ASP.NET MVC 3, which included the new Razor view engine. I’ve been really excited about it as I feel it makes our views a lot prettier than before with Web Forms view engine. It will also be a lot quicker and smoother to type without all those messy <%-characters.

To the point! I am currently upgrading an existing site to use MVC 3 and Razor. However in this first preview of MVC 3 we won’t have any File Colorization or IntelliSense in .cshtml files. This means it will look like we’re editing in Notepad. It got me wondering if there was a way to at least get some colorization, more specifically HTML colorization. I wandered around in the options of VS2010, and eventually found the place where I could map an extension to a different colorization.

This is how you get HTML colorization in .cshtml files:

  1. Open Tools menu.
  2. Choose Options…
  3. Go to Text Editor, and third choice; File Extension.
  4. Enter cshtml as Extension and choose HTML Editor in the dropdown.
  5. Click Add and OK. Now try to open a .cshtml file – you should get HTML colorization.

Remember to remove this setting when VS2010 officially gets Razor colorization and IntelliSense.

That’s it. Hopefully it will be a little bit easier on your eyes.

 

Comments

No comments yet.

Write a comment

Required: Login with OpenID to post a comment. It is quick, easy and safe

Name: *
Email:
(never displayed - used for Gravatar)
Website:
Message: * Allowed tags: b, i, a, code, pre, blockquote, strike