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.
First version thanks to Keith Hall. Rebuilt by Michael Lyons. Also see LoneBoco's version.
- Support for many
@expressions - See Known Issues below for exceptions
- Hotkey comment/uncomment server-side comments (Ctrl+/ or Cmd+/)
- Trouble with
@(in CSS- or JS-embedding HTML attributes if the expression contains the tag string delimiter. - No support for
@bindattributes. - Chaining expressions together like
@if-for-etc. may require curly braces, even for single commands. - File new issues on GitHub