Visual Studio C# 2008:键入时出现代码折叠问题

发布于 2024-10-03 18:17:53 字数 669 浏览 0 评论 0原文

我在代码折叠方面遇到以下问题:如果我有一个具有折叠方法的类,并且我在这些方法之间插入代码,则下部代码会自动展开。例如:

class A
{
   void Method1() [ folded ]

   void Method2() [ folded ]

   void Method3() [ folded ]
}

如果我在方法 1 和 2 之间插入代码,则在键入过程中会发生以下情况:

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! ]
   }
}

是否有选项可以禁用 Visual Studio 完成的“智能”自动展开功能?我只想插入方法 4 并保留方法 2 和 3 折叠。由于自动展开,我必须再次手动折叠方法2和3。

我怀疑当我输入左括号时,VS 尝试寻找右括号,但我找不到任何禁用括号匹配的选项。

感谢这里的任何帮助。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

强辩 2024-10-10 18:17:53

提示/技巧/解决方法:您可以首先输入右括号。
当我想要注释块时,这通常是我避免展开代码的方法(从所需块末尾的结束标记“* /”开始,然后仅插入我的开始标记“/ *”

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 '/ *'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文