“全部折叠”或“切换轮廓”在 SQL Server Management Studio 2008 中
SQL Server Management Studio 2008 中的一项新功能是“大纲”(折叠区域的能力)。太棒了。但是,默认情况下所有区域都会展开。我似乎找不到“全部折叠”的方法(在 Visual Studio 中也称为“切换大纲”)。有人知道有办法做到这一点吗?我的任务是审查一个 3,000 行的存储过程,并且逐一折叠区域非常麻烦。
A new feature in SQL Server Management Studio 2008 is 'outlining' (the ability to collapse regions). It is awesome. However, by default all regions are expanded. I can't seem to find a way to 'collapse all' (also called 'toggle outline' in Visual Studio). Is anyone aware of a way to do this? I've been tasked with reviewing a 3,000 line stored procedure, and collapsing regions one-by-one is cumbersome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
这不是快捷键,但查询编辑器中有一个菜单选项可以执行此操作。
打开您的查询,然后转到“编辑”>“概述>切换所有大纲。
这将切换(即展开/折叠)查询中的所有节点。
This isn't a shortcut key, but there is a menu option in the Query Editor to do this.
Open your query and then go to Edit > Outlining > Toggle All Outlining.
This will toggle (i.e. expand/collapse) all nodes in the query.
看来这个功能不存在。已推荐给微软。我建议投票赞成;
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx ?FeedbackID=368542
作为解决方法,我使用 Notepad++ 在本地进行编辑。它的区域识别性不太好,但总比没有好。
It appears this feature does not exist. It has been recommended to Microsoft. I suggest voting it up;
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=368542
As a work-around, I'm using Notepad++ to edit locally. Its region identification isn't as good, but it's better than nothing.
解决方法是使用 BEGIN 和 END。
然后您将能够折叠 BEGIN。
A workaround is to use BEGIN and END.
You will then be able to collapse the BEGIN.
在 ssms 2017 ->工具>中有一个选项选项{参见图片}
下面说明了 @Triynko 对 @Shawns 答案的更新
In ssms 2017 -> There is an option in Tools > Options {see image}
The below illustrates @Triynko update to @Shawns answer
SSMS 有一个免费的第 3 方插件,称为 SSMS Tools Pack。它提供了一些有用的功能,其中包括可折叠区域和调试部分。默认情况下,当您首次打开 .sql 脚本时,区域会折叠。
http://www.ssmstoolspack.com/Features?f=9
例如:
There is a free 3rd party add-in for SSMS called, SSMS Tools Pack. It provides several useful features, which includes collapsable regions and debug sections. By default, the regions are collapsed when you first open a .sql script.
http://www.ssmstoolspack.com/Features?f=9
For example:
如果您在 Visual Studio 中打开 .sql 脚本,则可以折叠其中的代码。
If you open a .sql script in Visual Studio then you can collapse the code in there.
在我的情况下,“最大脚本大小”默认为 1MB,我的是 1Mb 以上,将其更改为 5MB,它可以工作
路径是
“工具”>>选项>>文本编辑器>> TransactSQL>>智能感知>>最大脚本大小
In my condition it was "Maximun Script Size" default is 1MB, mine was above 1Mb changed it to 5MB it works
Path is
Tools >> Options >> Text Editor >> TransactSQL >> Intellisense >> Maximum Script Size
我发现有用的选项...
Edit.ToggleAllOutlined
在 SSMS 2019 ->工具>选项>环境>键盘,然后单击命令 Edit.ToggleAllOutlined 并分配新的快捷键。
选项屏幕截图
警告截图
我使用了 Ctrl+K、Ctrl+T。
然后在 Query 的开头放置一个 GO,并在我想要折叠的任何区域之后放置 GO。我尝试了 BEGIN END,但它折叠了整个查询。
请尝试以下操作:
An option that I found helpful...
Edit.ToggleAllOutlining
In SSMS 2019 -> Tools > Options > Environment > Keyboard, then click on command Edit.ToggleAllOutlining and Assign your new shortcut keys.
Screenshot of Option
Screenshot of Caution
I used Ctrl+K, Ctrl+T.
Then put a GO in the beginning of Query and GO after any region I wanted collapsed. I tried BEGIN END, but it collapsed entire Query.
Try it out with the following:
Ctrl+M、Ctrl+A 是 SSMS 17.X 中的默认设置。
您可以通过转到“工具”>“工具”来更改此设置。选项>环境>键盘,然后单击命令 Edit.CollapseAllOutlined 并分配新的快捷键。
Ctrl+M,Ctrl+A is the default in SSMS 17.X.
You can change this by going to Tools > Options > Environment > Keyboard, then click on command Edit.CollapseAllOutlining and Assign your new shortcut keys.
CTRL + M 然后 CTRL + L
全部在 Visual Studio 2022 中折叠/展开
CTRL + M then CTRL + L
collapse / decollapse all in visual studio 2022
此功能已在 SQL Server Management Studio 2012 中实现,并且可用于除使用 CTRL + M 等之外的版本 - https://msdn.microsoft.com/en-us/library/ms174205(v=sql.110).aspx
This feature was implemented in SQL Server Management Studio 2012 and is available for editions beyond also using CTRL + M etc - https://msdn.microsoft.com/en-us/library/ms174205(v=sql.110).aspx