Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting Razor Files in Visual Studio Code

Anyone have a good solution for formatting Razor files inside of VSCode? I've tried making it work with prettify-vscode and beautify. But in both cases it can't tell that cshtml files. I don't want to change my razor to html as I'll lose a lot of the razor-ness.

like image 422
Shawn Wildermuth Avatar asked Jan 12 '18 23:01

Shawn Wildermuth


1 Answers

You can introduce them as HTML files (File -> Preferences -> Settings) without any 3rd party extensions:

{   "editor.formatOnSave": true,   "emmet.includeLanguages": {     "aspnetcorerazor": "html"   },   "files.associations": {     "*.cshtml": "html"   } } 

Update: v1.17.0 of C# for Visual Studio Code add-on added preview Razor (cshtml) language service with support for C# completions and diagnostics.

like image 172
VahidN Avatar answered Sep 17 '22 10:09

VahidN