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


Discussion is closed. Login to edit/delete existing comments.

  • Eugene Ivanoff 0


  • Ricky Chong 0


  • JyKa Lu 0

    Very Helpful! I didn’t know this feature existed before.

  • Kirsan 4

    It would be nice to enable this functionality by hotkey – for example, while holding alt.

    • anonymous 0

      this comment has been deleted.

    • Abhijit Shrikhande 0

      Yes. I agree. Can we get a shortcut key to switch between outer and inner?

      • Leah TranMicrosoft employee 1

        Thanks for the feedback about switching between outer and inner scopes! Would you share more about when you need to switch between these settings?

        • anonymous 0

          this comment has been deleted.

  • Kwafo Isaac 0

    Please one question
    Can one use visual studio to create an APP for android, windows and IOS. And how can i do that

  • Lasse Pedersen 1

    This is cool, but there really ought to be a hotkey or toolbar button to toggle this.

  • Daite Dve 0

    While main idea is right, implementation is clumsy (as usual). Obviously it’s quite inconvenient to jump to options “prefer outer/inner scope” as well as switching this feature ON at all. Even students understand this feature must be activated BY A KEY.

    • Leah TranMicrosoft employee 1

      Thanks for the feedback about how it’s inconvenient it is to turn this on! Would you share more about why it would be helpful to activate these via the keyboard? Is this a feature that you would often need to turn on and off?

  • O.D 0

    that’s great! I waited a long time for this feature, thanks a lot!

Feedback usabilla icon