I am in a view editing HTML and I may for example need one line of C# code inside <% %> tags..
If that C# code contains a bracket like { or } after I press enter or complete the command, VS automatically spreads the line over 2 lines to kind of auto-indent the brackets.
It's really annoying because I am not in code view, I just want my view to look super clean and therefore keep the C# indentation exactly how I typed it in.
Any idea how to disable this???
Many thanks..
Every Visual Studio auto-indent operation is being saved in the Undo history. This means that if you press Ctrl+Z (undo) immediately after the auto-indent, it will be canceled and the code will be reverted to the initial indentation. This undo operation will not affect any characters that you have entered, only the auto-indentation.
It is still annoying, since it requires an additional keyboard input, but for many situations it is a good enough workaround.
Yeah, I've experienced that too... Hate it when VS does that. But the only way to do it, that I know of, is disabling C#'s "Automatically format completed block on }"...
Go to Tools | Options | Text Editor | C# | Formatting | General and uncheck it.
BUT you will lose this feature for all C# code (not only in views)...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With