Sticky Scroll: Stay in the Right Context

Leah Tran

When coding in a long file, it’s easy to lose track of the method or block you’re writing in. Or when scrolling through an unfamiliar codebase, it can become disorienting where you are in the code.

Sticky Scroll can help you stay in the right context by sticking helpful scopes, including namespaces, classes, methods, loop initialization statements, and conditionals. Multiple code formats are supported, including C#, C++, XAML, and JSON. With a single click on a line in the Sticky Scroll header, you can quickly navigate directly to that line of code. Learn more about it from the previous blogpost.

We first released Sticky Scroll in 17.5 Preview 2 and it’s now moving into the latest 17.6 release! Since our last update, we’ve added a new option to stick inner scopes so you can easily track the scopes that are closer to what you’re working on.

Let us know what you think of Sticky Scroll in Visual Studio on this feedback ticket.

New: Choose between outer or inner scopes

We’ve heard feedback about how sticking outer scopes isn’t helpful. Oftentimes, the namespace and class name match the file name. It can feel wasteful to give up two lines of vertical space for info that is often obvious. Instead, it’d be more useful if lines that are likely to be different are shown instead.

In Options, you can configure whether outer or inner scopes are prioritized with “When number of scopes exceeds the maximum”.

“Prefer outer scopes” is set by default, which shows the higher-level scopes that come from the top of the file. The new option “Prefer inner scopes” shows lower-level scopes by pushing out higher-level scopes as you scroll through deeply nested code.

Tools > Options > General > Sticky scroll > “When number of scopes exceeds the maximum:”

“Prefer outer scopes” shows top-level scopes:Outer scopes stick in the header

“Prefer inner scopes” shows lower-level scopes:

Inner scopes push out outer scopes.

Try Sticky Scroll in Visual Studio 2022 17.6

Enable it in Tools > Options > Text Editor > General > Sticky Scroll by toggling the checkbox for “Group the current scopes within a scrollable region of the editor window.” But if you need to quickly turn it off, you can right-click on the Sticky Scroll area and click “Sticky Scroll”.

Please Share Your Feedback

Let us know what you think of Sticky Scroll in Visual Studio on this feedback ticket and report any issues you face so we can improve the experience.



Sticky Scroll requires Block Structure Guides to be enabled for some languages (e.g., C#). If Sticky Scroll is not working, try enabling the following options in Tools > Options > Text Editor > C# > Advanced.

Option Description
Show guides for declaration level constructs Affects namespaces, classes, method initializations
Show guides for code level constructs Affects conditionals, loops