Skip to content

Sublime Text syntax highlighting for HTML with embedded C#: WebForms/ASP.Net and Razor

License

Notifications You must be signed in to change notification settings

michaelblyons/SublimeSyntax-HTML-CSharp

Repository files navigation

Sublime Text syntax highlighting for .cshtml, .aspx, and similar files.

Current support

Highlighting

  • Embedded C# (<script runat="server">)
    • The runat="server" must immediately follow the tag opening.
  • <% expressions (including <%=, <%#, <%:, <%$, <%--)

Functionality

  • Hotkey comment/uncomment server-side comments (Ctrl+/ or Cmd+/)

  • Snippets for <%-ish expressions

  • Snippets for some directives (Try page or import)

    • Default attributes are subject to change.
  • Snippets may require Ctrl+space, depending on your environment.

  • Some autocomplete within directives.

Razor syntax

A huge thank-you to @keith-hall for this!

Future support (maybe)

  • Identify more attributes of directives
  • Autocomplete ASP builtins

Known issues:

  • "Goto Anything" support is poor.

  • No recognition of excluded scopes to return to HTML. In the snippet below, the C# scope ends immediately after "bar.

    <%
      var foo = "bar%>";
    %>
    
  • Javascript does not always recognize that Response.Write output is coming. The ) is marked as invalid and the conditional scopes are never terminated.

    <script type="text/javascript">
    if (true && <%= list.Any() %>) {
       doStuff();
    }
    </script>
    

About

Sublime Text syntax highlighting for HTML with embedded C#: WebForms/ASP.Net and Razor

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published