Visual Studio XML File Editor Lowercase

2019-03-28 16:03发布

I'm editing cshtml in Visual Studio (with a .cshtml file extension). I auto format or paste in some xml (which triggers an auto format) and Visual Studio lowercases all my xml attributes (so theAttribute > theattribute).

This is wrong. How can I fix? I don't see a relevant option under Tools > Options.

4条回答
不美不萌又怎样
2楼-- · 2019-03-28 16:54

Tools->Options->Text Editor->XML->Formatting (*) Preserve manual attribute formatting

also, uncheck the other settings. Do you have Resharper or something else that could be affecting it as well?

查看更多
何必那么认真
3楼-- · 2019-03-28 16:57

I haven't found a way to configure this behavior, but as workaround you can explicitly select editor to be used with *.cshtml files and then it works properly.

Go to Tools -> Options -> Text Editor -> File Extension

enter image description here

P.S. It looks like there were plans for HTML (Razor) text editor settings in a separate node, but I don't see it in release of VS 2013. See HTML Editing Features in Visual Studio 2013 Preview

Also I saw that Tools -> Options -> Text Editor -> HTML (Web Forms) -> Formatting has options which specifically mention the behavior you are getting.

查看更多
淡お忘
4楼-- · 2019-03-28 16:58

You may also want to try this:

  • Options
    • Text
      • Editor
        • HTML
          • Advanced
            • Format on paste: False
            • Enable validation: False
查看更多
戒情不戒烟
5楼-- · 2019-03-28 17:05

Try Tools -> Options -> Text Editor -> Html -> Advanced then set "XHTML coding style" false and set "Format on paste" false

查看更多
登录 后发表回答