CSHTML files

CSHTML files

2
NewbieNewbie
2

    Aug 18, 2014#1

    I am trying to edit CSHTML files (Razor/Webmatrix) and color coding would be nice. Are there any dictionary files to help with this?

    thanks

    115
    Power UserPower User
    115

      Aug 18, 2014#2

      There isn't a Razor wordfile already written and I'm not sure it would be easy or even possible at all to create using the current wordfile parsing. As I understand it, Razor is an even more simple way of inserting code into HTML than the regular ASP conventions. VB and C# inline statements, single line statements and code blocks are embedded in HTML, marked by the @ symbol and {} (but no {} for inline statements). The @ symbol is also used to indicate a literal string in C#, so it can be present inside the {} delimiters. It is not required to explicitly close a statement/code block with the trailing } character. The next tag closes the statement/block.

      <!-- Single statement blocks -->
      @{ var total = 7; }
      @{ var myMessage = "Hello World"; }

      <!-- Inline expressions -->
      <p>The value of your account is: @total </p>
      <p>The value of myMessage is: @myMessage</p>

      <!-- Multi-statement block -->
      @{
      var greeting = "Welcome to our site!";
      var weekDay = DateTime.Now.DayOfWeek;
      var greetingMessage = greeting + " Today is: " + weekDay;
      }
      <p>The greeting is: @greetingMessage</p>

      6,681583
      Grand MasterGrand Master
      6,681583

        Aug 19, 2014#3

        Open Advanced - Configuration - Editor Display - Syntax Highlighting, select language HTML, click on button Open and close the configuration dialog with button Cancel.

        Following is possible at the moment:

        In first line insert left to File Extensions = the definition:

        Code: Select all

        Block Comment On Alt = @{ Block Comment Off Alt = }
        That results in highlighting a block starting with @{ and ending with } with the color for alternate block comments which can be customized under View - Themes - Manage Themes on tab Syntax for language HTML.

        Additionally append at bottom of html.uew:

        Code: Select all

        /C4"Razor Statements"
        ** @
        That is a substring definition to highlight all words starting with @ with color 4 named Razor Statements. The colors for this color group can be also configured in the manage themes dialog.

        For a better support like a real multi-language syntax highlighting support with detection of Razor blocks and single statements in a HTML file it would be necessary that developers of IDM add the detection rules for Razor to code of UltraEdit and introduce a new language marker keyword for Razor making it possible to use a complete wordfile for Razor to highlight keywords and strings in a Razor code block. You can send a feature request email to IDM support regarding such an enhancement with explaining in detail how Razor blocks inside HTML code can be identified.

        One question:

        @ is a common character in HTML files because of being part of email addresses.

        How does Razor interpreter distinguish if @ belongs to an email address or should be interpreted as literal character in text, or marks a single Razor statement?
        Best regards from an UC/UE/UES for Windows user from Austria