Visual Studio 2010 Auto-Formatting
I have the Productivity Power Tools extension installed on my machine, as well as VS 2010, but I seem to have developed a mysterious issue.
The IDE no longer auto-formats code when I enter a ;
or }
which is quite annoying, I made particular use of the auto-format on }
option.
I found this question, but that doesn't solve my problem either (the settings suggested there were already the same in my IDE).
I can't really offer more information at the minute, it was working yesterday, I came into work this morning and it's just stopped开发者_C百科 working, I haven't changed any settings at all. Any help would be massively appreciated.
Typically I've seen this when my code wouldn't build, or I'd missed a closing brace } somewhere (or something similar), usually above the code that I'm looking at. Check that the code builds first just to remove it as a possibility, then try a forced auto format from the menu (Edit > Advanced > Format Document (Ctrl + K, Ctrl + D)). Does it still not work?
This may not solve the issue, but should help refine the problem.
This happened to me. Closing files and closing VS didn't help, and it's not the case of a missing bracket in the code. Somehow the Formatting setting got changed by some black magic in VS.
Here's where the setting is in VS 2010:
Tools ⇒ Options ⇒ Text Editor ⇒ C# ⇒ Formatting ⇒ Wrapping ⇒ Leave block on Single Line.
Uncheck the checkbox, and the lines will wrap when you enter the closing bracket.
Old issue I know, but classic MS solution that hasn't been mentioned: close the file and/or VS and start again (sometimes just the file is enough, sometimes VS).
This happens a lot if you have the file open for a long time / lots of edits. VS just gets fed up / bored / confused / overwhelmed.
精彩评论