仅折叠C#(Visual Studio)中的所有#regions(!) [英] Collapse all #regions only(!) in C# (Visual Studio)

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

问题描述

有许多键盘快捷键和菜单命令可以自动扩展或折叠当前文档中的所有可折叠文件夹. Ctrl + M Ctrl + L 递归地切换所有可折叠对象,从顶部命名空间到内部方法和注释.基本上所有在左边距带有[+]图标的东西. Ctrl + M Ctrl + O 的作用不大,但仍然触及类中的方法和注释

There's a number of keyboard shortcuts and menu commands to automatically expand or collapse all foldables in the current document. Ctrl+M, Ctrl+L 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. Ctrl+M, Ctrl+O 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的工作解决方案:

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 ,它将扩展所有区域以快速浏览整个文件.通过按 Ctrl Q 热键并键入Coll resp,可以快速使用这些命令. Exp,然后按 Enter (假设您没有其他具有相同前缀的命令).

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 CtrlQ hotkey and typing Coll resp. Exp, then pressing Enter (supposed you don't have other commands with the same prefix).

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆