Can I exclude part of code from Format Document in Visual Studio

Go To StackoverFlow.com

3

I have some transliteration tables in code that are formated to make it easier to see pairs, simplified example :

  oldChar = new string[] { "Æ",  "æ",  "Å", "å", "Ä", "ä", "Ø", "ø", "Ö", "ö" };
  newChar = new string[] { "AE", "ae", "A", "a", "A", "a", "O", "o", "O", "o" };

and as a habit I am often using Visual studio Format Document command, and naturally that command turn this piece of code into this :

  oldChar = new string[] { "Æ", "æ", "Å", "å", "Ä", "ä", "Ø", "ø", "Ö", "ö" };
  newChar = new string[] { "AE", "ae", "A", "a", "A", "a", "O", "o", "O", "o" };

can I tell it to leave this part alone, for region perhaps ?

2012-04-04 22:55
by Antonio Bakula


0

Unfortunately no you can't. The format command either works against the entire document or a selection of text. It can't be told to format and exclude a particular section.

Couple of really hacky options I thought of

  • Comment out the lines, format, the uncomment
  • Write a macro to format the selection above, then below
2012-04-04 23:03
by JaredPar
Ads