How to stop VS Commnity 2022 from auto inserting closing tags in cshtml files?

Viewed 30

I am returning to programing after a 3ish year break and am now trying to use VS 2022 Community. I am writing an ASP.Net Core application using MVC and as I am writing my HTML markup in the .cshtml file it keeps auto-inserting the closing tag. I HATE this function but I can't find a way to turn it off. I have gone though and unchecked every "closing tag" auto insert I could find under Options -> Text Editor and even restarted the application but it still does it. I don't know if I missed something or if this is now not an option but can anyone tell me how to shut this off? If it makes any difference the file is in /Views/Shared/ folder.

Also, yes. I did try googling for this and everything I find that is relevant applies to VS code which is very different.

If this is the wrong forum for this question please point me to the right one and I will remove this and ask over there.

1 Answers

I checked over the various settings as you did, and it seems that this is not an option anywhere.

Under Tools → Text Editor → HTML → Advanced there is an "Auto insert closing tag" boolean. Setting it to false, it doesn't work for .cshtml files - only regular HTML files. Since there isn't any .cshtml specific setting under the text editor section of the options, I don't think this behavior can be changed.

The "best" workaround I found was immediately performing an undo (Ctrl + Z) after the ending tag gets automatically inserted will remove it.

Related