"collapse all' or "toggle outline" in SQL Server Management Studio 2008

Viewed 66483

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.

10 Answers

In ssms 2017 -> There is an option in Tools > Options {see image}

The below illustrates @Triynko update to @Shawns answer

enter image description here

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

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:

/*
Toggle using Tools > Options > Environment > Keyboard
Search for "Toggle"
Select Edit.TogleAllOutlining
Enter Global Shortcut key.  Do not use common keys like ctrl-A, ctrl-c, ctrl-v, etc...
    Pay attention to "Shortcut currently used by: (dropdown values)"

I used ctrl-k, ctrl-t
*/  
GO

    --Do something
    Declare @Something varchar(max)
GO
    /*First Region*/    
    select 'parent - this will be toggled'
    
    select 'sub query - toggled with parent'
GO
    /*Second Region*/   
    select 'parent - this will be toggled too'
    
    select 'sub query - toggled with parent'
GO

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.

Related