This project contains syntax highlighting and completions in Sublime Text for .cshtml, .aspx, and similar files. It was originally created for .Net WebForms, but later expanded to support Razor syntax as well.
Microsoft's ASP.Net pages with C# were the first thing that this package supported. The syntaxes also work for .Net MVC. The ASP syntax that Sublime Text ships with only supports Visual Basic.
- Embedded C# script blocks (
<script runat="server">)- The
runat="server"must immediately follow the tag opening.
- The
- ASP.Net inline expressions
- Server-side comments (
<%--) - Directives (
<%@) - Output (
<%=,<%#,<%:,<%#:,<%$) - Embedded code blocks (
<%)
- Server-side comments (
- Hotkey comment/uncomment server-side comments (Ctrl+/ or Cmd+/)
- Snippets for
<%-ish expressions - Snippets for some directives (Try
pageorimport)- Default attributes are subject to change.
- Snippets may require Ctrl+Space, depending on your environment.
- Some autocomplete within directives.
- Basic "Open CodeBehind" shortcut for frontend pages.
- Naive "Open Front End" shortcut for codebehind files.
- Identify more attributes of directives
- Snippets and/or completions for ASP.Net builtins
- Nothing yet? 🤞
- File new issues on GitHub
Microsoft later released a simplified, less-intrusive frontend templating syntax that supplanted WebForms.
A huge thank-you is owed to @keith-hall for his work on this.
- Support for many
@expressions - See Known Issues below for exceptions
- Hotkey comment/uncomment server-side comments (Ctrl+/ or Cmd+/)
- Trouble with
@(in HTML attributes if the expression contains" - Trouble with
@expressions in HTML attributes if they are inside@block expressions - Trouble with
@expressions in embedded languages (i.e. in JavaScript) if they are inside@block expressions - File new issues on GitHub