Visual Studio
Code Editor Features
Word Highlighting
Scrollbar
Software Development

Visual Studio 2017 2019 highlight occurrences of selected word in scrollbar

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Visual Studio Scrollbar Highlights in 2017 & 2019

In software development, quick navigation and easy reference to specific portions of code are vital for productivity. Among the numerous features of Visual Studio, the ability to highlight occurrences of selected words or tokens on the scrollbar plays a crucial role in enhancing user experience and efficiency. This feature was improved and expanded in Visual Studio 2017 and refined further in Visual Studio 2019.

Scrollbar Overview

The scrollbar in Visual Studio is not just a navigation tool; it also functions as a mini map of your code. Beyond simply indicating where you are in a file, it can be configured to display different types of markers, one of which highlights occurrences of the selected word.

The highlighted occurrences allow developers to quickly see where a particular variable, method, or class is used throughout the document, easing navigation and supporting more effective debugging and refactoring.

Configuring the Scrollbar

Visual Studio 2017

In Visual Studio 2017, a rich scrollbar mode can be enabled to show annotations, including those for identifying the locations of certain code symbols. The following steps configure the scrollbar:

  1. Enable Rich Scrollbar
    • Go to `Tools` > `Options`.
    • Navigate to `Text Editor` > `All Languages` under the `Display` section.
    • Check `Show vertical scroll bar` and ensure `Use map mode for vertical scroll bar` is selected.
  2. Highlight Occurrences
    • Within `Tools` > `Options`, browse to `Environment` > `Preview Features`.
    • Enable the necessary settings for enhanced viewing, like showing the identifiers in the code.

Once properly configured, simply selecting a word in the text editor will cause all occurrences of that word throughout the document to be highlighted both in the text and within the scrollbar mini map.

Visual Studio 2019

Visual Studio 2019 carries forward the scrollbar features of its predecessor but with improved performance and additional settings for enhanced customization. The setup is similar but includes some nuances:

  1. Customize Indicators
    • Open `Tools` > `Options`.
    • Go to `Text Editor` > `General`.
    • Here, you can fine-tune the types of annotations that appear on the scrollbar.
  2. Enhanced Visualization
    • Visual Studio 2019 introduced better performance in rendering the minibars and enhanced its clarity, especially on high-definition monitors. The highlighting feature works seamlessly even within large files.

The improvements in Visual Studio 2019 over previous versions make the feature more reliable and less intrusive in terms of rendering.

Use Case Examples

  1. Debugging
    • Imagine tracking the usage of a `status` variable within a large codebase during debugging sessions. By selecting the `status` variable, every occurrence gets highlighted, providing a quick overview of where and how it is manipulated.
  2. Refactoring
    • When performing refactoring, identifying all uses of a method before renaming it is crucial to avoid breaking changes. The scrollbar highlights facilitate this by providing a bird's-eye view of the occurrences.

Key Points Summary

FeatureVisual Studio 2017Visual Studio 2019
Rich Scrollbar ModeAvailable but less refinedEnhanced with better rendering and customization
ConfigurationThrough Text Editor optionsSimilar but with enhanced option fields
Use CasesDebugging, tracking variable usageDebugging, variable tracking, code overview
PerformanceGood but may lag in large filesImproved, especially for larger files and visuals
Visual EnhancementsBasic highlightingEnhanced highlighting, clearer on high-resolution

Conclusion

The occurrence highlighting on the scrollbar in Visual Studio 2017 and 2019 exemplifies a thoughtful design aimed at improving developer efficiency. As the IDE has evolved, so too have its features, enhancing the ability for developers to manage and understand complex codebases quickly.

While Visual Studio 2017 set a solid foundation, 2019 expanded and refined these features to better accommodate the needs of modern developers, ultimately reinforcing Visual Studio's commitment to providing a premier development environment.


Course illustration
Course illustration

All Rights Reserved.