When using "Keep tabs" instead of the default "Insert spaces", and running "Fomat document" (CTRL-E, CTRL-D) on in a .cshtml file with razor code any ifs inside other markup gets "mangled". I've attached a screenshot with a comparison of space and tab formatting.
Repro:
In Visual Studio 2012 (I'm using premium), create a new ASP.NET MVC 4 project (using the default web site template).
Open "Tools"->"Options"->"Text Editor"->"All Languages"->"Tabs" and set "Keep tabs" instead of "Insert spaces".
Open any view (.cshtml) and insert:
<div>
@if(true) {
}
</div>
Run format document (CTRL-E, CTRL-D).
Comments: This issue has existed for more than two years now. How hard can it be to fix this really? Apparently very hard. One of the team members, on StackOverflow: > It does not work correctly in all cases because it's a difficult problem to solve. ``` <div> @if (true) { <div> <div> @if (true) { } </div> </div> } </div> ``` Now look closely. The first @if is indented with one tab. With how many spaces is the { indented? One space. The second @if is indented with three tabs. With how many spaces is the { indented? Three spaces. I'm beginning to think you guys secretly hate tabs, and decided you wanted to end the "tabs vs spaces" holy war.
Repro:
In Visual Studio 2012 (I'm using premium), create a new ASP.NET MVC 4 project (using the default web site template).
Open "Tools"->"Options"->"Text Editor"->"All Languages"->"Tabs" and set "Keep tabs" instead of "Insert spaces".
Open any view (.cshtml) and insert:
<div>
@if(true) {
}
</div>
Run format document (CTRL-E, CTRL-D).
Comments: This issue has existed for more than two years now. How hard can it be to fix this really? Apparently very hard. One of the team members, on StackOverflow: > It does not work correctly in all cases because it's a difficult problem to solve. ``` <div> @if (true) { <div> <div> @if (true) { } </div> </div> } </div> ``` Now look closely. The first @if is indented with one tab. With how many spaces is the { indented? One space. The second @if is indented with three tabs. With how many spaces is the { indented? Three spaces. I'm beginning to think you guys secretly hate tabs, and decided you wanted to end the "tabs vs spaces" holy war.