Block auto-ignore command in visual studio

I like to use the automatic formatting tool in Visual Studio. CTRL K + CTRL DHowever, there are times when VS does the formatting a little bit from what I want, if, for example, I make a detailed kind of pseudocode that relies on specific comments and indents. Is there a way that I can still use the command CTRL K + CTRL Dand set up visual studio to ignore a specific block of code or a set of line numbers? In addition, if there is an answer in VS 2013, but not in 2012, send a message, because I may be in the near future. Thanks in advance.

+4
source share
1 answer

Today I ran into this problem with my pseudo-code comments and thought that I would share the way I solved.

While there is no way to prevent automatic formatting of parts of Visual Studio code, there is a way to prevent automatic formatting of comments with pseudo-code .

Instead of using something like this

  // if condition
     // do this
  // else
     // do something else

use triplex slashes ///instead

  /// if condition
  ///    do this
  /// else
  ///    do something else

As a bonus, you get automatic insertion/// in new lines and automatic indentation , which preserves the level of indentation of previous lines.

It does not depend on the indent parameters of the editor. It also will not ruin the XML documentation.

(, , . , , .)

+2

All Articles