Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I collapse SQL in VS Code?

I checked the documentation for code collapsing, many languages have a marker defined but SQL doesn't.

SQL Server Management Studio recognizes begin and end as a region, allowing for folding, but VS Code doesn't.

Any suggestions are very appreciated.

like image 642
VirtusO Avatar asked Jan 26 '26 17:01

VirtusO


1 Answers

For anyone coming here for the answer.
Region markers for SQL have been added to VS CODE in 2019 and you can now use them as:

--#region [name region if you like]
part of code you want to fold/collapse
--#endregion

Then use Ctrl + Shift + P or View -> Command Palette... and choose Fold All Regions.

like image 183
Maciej Czapiewski Avatar answered Jan 29 '26 13:01

Maciej Czapiewski