Microsoft have an extension for Visual Studio that does this (and also shrinks lines with {}), I use it every day.
https://marketplace.visualstudio.com/items?itemName=VisualSt... (there’s been a version for the last few versions of Visual Studio too)