I probably don’t use this a lot but it’s still handy to know. Have you noticed when you create a function that you get a chevron on the gutter between line numbers and line start?
Folding regions are based on lines of code that have similar indentation like inside a function, script block, comment help etc.
But I recently discovered how to collapse a group of lines with the use of the region comment, see below
#region codes
Write-Information "Command = $($myinvocation.mycommand)" -Tags Meta
Write-Information "PSVersion = $($PSVersionTable.PSVersion)" -Tags Meta
Write-Information "User = $env:userdomain\$env:username" -tags Meta
#endregion
So for example, when you hover over the line where the #region comment is you will get the chevron to collapse everything between #region and #endregion.
Keyboard Shortcuts
Furthermore you can use shortcuts to collapse a group of text like a region or script block, just click a line within the group you want to collapse and then use:
Fold: Ctrl + Shift + [
Unfold: Ctrl + Shift + ]
Outline
Another handy thing I noticed is that in the outline pane in VS Code, regions and blocks of code are displayed in a tree making it easy to jump to certain parts of your script. If you give your region good descriptions then it will be make it easier to navigate long scripts.