2

I have the following problem with code folding: if I have a class with folded methods, and I insert code in between these methods, the lower code unfolds automatically. E.g.:

class A
{
   void Method1() [ folded ]

   void Method2() [ folded ]

   void Method3() [ folded ]
}

If I insert code between Methods 1 and 2, the following happens in the midst of typing:

class A
{
   void Method1() [ still folded: good ]

   void Method4( [I typed until here and pause]

   void Method2()
   {
      [ unfolded by VS... do not want this! ]
   }

   void Method3()
   {
      [ more auto unfolding... ugh! ]
   }
}

Is there an option to disable the "smart" auto-unfolding done by Visual Studio? I just want to insert Method 4 and keep Methods 2 and 3 folded. As a result of the auto-unfolding, I have to manually fold Methods 2 and 3 again.

I suspect when I typed the open bracket, VS tries to look for a close bracket, but I can't find any option to disable bracket-matching.

Appreciate any help here.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
David Ong
  • 117
  • 1
  • 7

1 Answers1

1

Hint/Trick/Workaround : You could start off by typing the closing bracket first. This is Usually how I avoid unfoldind code when I want to comment blocks (start by the closing tag '* /' at the end of the desired block, and then only insert my opening tag '/ *'

Mehdi LAMRANI
  • 11,289
  • 14
  • 88
  • 130
  • You can also try to select the block that you want to comment and press: Ctrl + K followed by Ctrl + C to comment the code and Ctrl + K followed by Ctrl + U to uncomment. – Adrian Fâciu Nov 24 '10 at 07:59
  • Yes that's what I usually do, except for large blocks where code readability is burdened by all these '//' at the beginning of each line. – Mehdi LAMRANI Nov 24 '10 at 08:17