10

I have Resharper and Web Essentials installed in Visual Studio 2013, and would like to have the contents of an HTML tag in my .cshtml files be indented.

So what I do NOT want (and seems to be the default):

<html>
<body>
    <h1>Hello!</h1>
<body>
</html>

I DO want it to look like:

<html>
    <body>
        <h1>Hello!</h1>
    <body>
</html>

I've removed everything from Resharper -> Options -> Code Editing -> HTML -> Formatting Style -> Do Not Indent Children Of.

I've also checked Tools -> Options -> Text Editor -> HTML (Web Forms) -> Formatting -> Tag Specific Options -> Client Specific Tags -> html -> Indent Contents to no avail.

Note that I don't have a Tools -> Options -> Text Editor -> HTML -> Formatting, instead I have two subtrees, HTML and HTML (Web Forms), where only HTML (Web Forms) has the Formatting option.

Anyone know of a way to get Visual Studio to do this? It's very annoying to see my perfectly formatted HTML document go out the window whenever I add a new tag. Thanks!

MatthewSot
  • 3,516
  • 5
  • 39
  • 58

2 Answers2

12

I'm a bit late to the party, but it looks like you can fix this by removing "html, body" from "HTML -> Formatting Style -> (Around tags) Do not indent children of"

See here: enter image description here

Sean Anderson
  • 27,963
  • 30
  • 126
  • 237
  • 1
    Thanks for the answer! In the original question, though, I had mentioned that I had removed all tags from that option in Resharper, so unfortunately this wasn't it (maybe they've fixed the bug since then, I would have to double-check now) – MatthewSot May 28 '15 at 05:58
  • It seemed to work for me in ReSharper 9.x, but it still had the issue with clicking 'Format Document' :( – Sean Anderson May 28 '15 at 06:23
  • 1
    Thank you! This was driving me nuts for way too long. – Bagzli May 26 '16 at 13:33
11

One more reason why Resharper doesn't indent tag content - size of tag. Look for option Resharper -> Options -> Code Editing -> HTML -> Formatting Style -> Do not indent children if tag size more than If count of lines too much, Resharper' formatter doesn't indnent it. Try to set value e.g. 10000

WinnieThePoooh
  • 289
  • 2
  • 3
  • 1
    I think that fixed it, though right-clicking and "format document" still undoes the indent :\ This at least fixes the while-typing corrections, though, thanks! – MatthewSot Dec 13 '14 at 00:31
  • It's strange behaviour. I've created issue [RSRP-429035](https://youtrack.jetbrains.com/issue/RSRP-429035) for it. It would be great if you'll attach some description to issue and code example – WinnieThePoooh Dec 13 '14 at 10:07