本文介绍了仅在 C# (Visual Studio) 中折叠所有 #regions(!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

有许多键盘快捷键和菜单命令可以自动展开或折叠当前文档中的所有可折叠内容.+,+ 递归地切换所有可折叠对象,从顶部命名空间到内部方法和注释.基本上所有在左边距中有 [+] 图标的东西.+, + 做的少了一些,但还是会触及到类内部的方法和注释.

There's a number of keyboard shortcuts and menu commands to automatically expand or collapse all foldables in the current document. +, + toggles all foldables recursively, from the top namespace down to the inner methods and comments. Basically everything that has a [+] icon in the left margin. +, + does it bit less, but it still touches methods and comments inside the class.

我正在寻找一个专门关注#region可折叠的功能,而不是其他任何东西.不是命名空间、类、注释或方法.我真的只想折叠那些用 #region 关键字明确标记的区域.

I'm looking for a function that specifically only regards #region foldables and nothing else. Not namespaces, classes, comments, or methods. I really only want to fold those areas that are explicitly marked as such with the #region keyword.

是否有任何隐藏的快捷方式或扩展程序?

Is there any hidden shortcut or an extension for that?

我更喜欢 Visual Studio 2015(目前为 RC)的键盘解决方案.

I'd prefer a keyboard solution, for Visual Studio 2015 (RC for now).

如果有人问为什么:我想获得文件的概览,但当我决定查看一个区域时立即查看所有详细信息.

In case somebody asks why: I want to get an overview of the file, but immediately see all the details when I decide to look inside one region.

更新:

由于这个问题已经收到了很多答案,其中一些没有用,其他一些已经过时,Visual Studio 2019 的工作解决方案可以在这个未被重视的答案中找到:https://stackoverflow.com/a/58999093/143684

As this question has received many answers, some of them useless, others outdated, the working solution for Visual Studio 2019 can be found in this underappreciated answer here: https://stackoverflow.com/a/58999093/143684

推荐答案

Visual Studio 扩展 Productivity Power Tools 2015 有一项名为快速启动任务"的功能,可将新命令添加到快速启动"菜单中.其中之一是CollapseRegions,它就是这样做的.

The Visual Studio extension Productivity Power Tools 2015 from Microsoft has a feature called Quick Launch Tasks that adds new commands to the Quick Launch menu. One of them is CollapseRegions and it does exactly that.

相反的命令是ExpandRegions,它扩展所有区域以便快速浏览整个文件.这些命令可以通过按下 热键并输入 Coll 来快速使用.Exp,然后按(假设您没有其他具有相同前缀的命令).

The opposite command is ExpandRegions and it expands all regions for quick browsing of the entire file. These commands can be used pretty quickly by pressing the hotkey and typing Coll resp. Exp, then pressing (supposed you don't have other commands with the same prefix).

这篇关于仅在 C# (Visual Studio) 中折叠所有 #regions(!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 20:55