Microsoft has announced that Visual Studio 2022 17.5 Preview 2 adds Sticky Scroll functionality to help improve users’ productivity. Sticky Scroll reminds you about which code you’re editing by keeping the relevant headers pinned above the scroll view. The feature isn’t on by default but you can switch it on by heading to Tools > Options > Text Editor > General > Sticky Scroll and toggling the “Show the nested current scopes during the scroll at the top of the editor” option.
Sticky Scroll is a little bit limited right now in terms of the languages that it supports but it will work when editing code written in C#, C++, XAML, and JSON. Microsoft said it will continue improving the feature so it may add Sticky Scroll support for languages in the future.
The Sticky Scroll feature will make namespaces, classes, and methods stick to the top of the editor as you scroll through the code. The Sticky Scroll portion grows and shrinks as applicable headers are passed. This should help you identify what part of the code you were editing without having to scroll up and look again, saving you time.
If you don’t like too much content being stuck at the top of the editor, you can limit the number of lines from the same place you enabled it. Just type in the number of lines you’d like next to “Define the maximum number of sticky lines to show:” and press OK. To get started with the feature, download the latest Visual Studio 2022 Preview.