I love using the Auto Formatting tool in Visual Studio CTRL K + CTRL D However, there are times when VS makes the formatting just a tad off from what I want if, for instance, I'm making a detailed kind of pseudo-code that relies on specific comments and indentation. Is there a way I can still use the CTRL K + CTRL D command and set visual studio to ignore a certain block of code or set of line numbers? Also, if there's an answer in VS 2013 but not in 2012, please post because I may be upgrading soon. Thanks in advance.
I got hit by this problem today with my pseudo-code comments too and thought I'd share the way I solved it.
While there is no way to prevent Visual Studio from auto-formatting parts of code, there is a way to prevent it from auto-formatting pseudo-code comments.
Instead of using something this like this
// if condition
// do this
// else
// do something else
use the tripple-slashes ///
instead
/// if condition
/// do this
/// else
/// do something else
As a bonus you get automatic insertion of ///
in new lines and auto-indenting that keeps previous row's indentation level.
This seems not to depend on editor indentation options. It also seems not to mess up XML documentation
(Yes, I know this is an old question. No, I do not want to take Cameron's right for accepted answer.)
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