Customize the scroll bar
When you're working with long code files, it can be hard to keep track of where everything is in the file. You can customize the scroll bar of the code editor to give you an overall picture of what's happening in your code.
Annotations
You can select whether the scroll bar shows annotations such as code changes, breakpoints, bookmarks, errors, and caret position.
Open the Scroll Bars options page by choosing Tools > Options > Text Editor > All Languages > Scroll Bars.
Select Show Annotations over vertical scroll bar, and then select the annotations you want to see. The available annotations are:
- changes
- marks
- errors
- caret position
Tip
The Show marks option includes breakpoints and bookmarks.
Try it out by opening a large code file and replacing some text that occurs in several places in the file. The scroll bar shows you the effect of the replacements, so you can back out your changes if you replaced something you shouldn't have.
Here's how the scroll bar looks after a search for a string. Notice that all instances of the string appear in the scroll bar.
Here's the scroll bar after replacing all the instances of the string. The red marks in the scroll bar show where the text replacement introduced errors.
Table of annotations
Curious as to which scroll bar annotations and their associated colors match which actions? See the following tables for details.
Code changes
Code changes are annotated in the far-left side of the vertical scroll bar.
Tracked files (in a Git repository)
Color | Default annotation | Status | Settings name |
---|---|---|---|
Green | Unsaved | Track additions in files under source control | |
Green | Saved | Track additions in files under source control | |
Red | Deleted | Track deletions in files under source control | |
Blue | Unsaved | Track modifications in files under source control | |
Blue | Saved | Track modifications in files under source control |
Untracked files (not in a Git repository)
Color | Default annotation | Status | Settings name |
---|---|---|---|
Gold | Unsaved | Track changes in files before save | |
Green | Saved | Track changes in files after save | |
Blue | Reverted | Track reverted changes in files |
Marks
Marks are annotated in the middle section of the vertical scroll bar.
Color | Default annotation | Settings name |
---|---|---|
Dark grey | Bookmark | |
Yellow | Find match | |
Dark red | Breakpoint | |
Light grey | Selection match | |
Blue | View definition |
Error, Warning, Information, or Suggestion
Errors, warnings, information, and suggestions are annotated in the far-right side of the vertical scroll bar.
Color | Default annotation | Settings name |
---|---|---|
Red | Syntax error | |
Green | Warning | |
Blue | Information | |
Light grey | Suggestion ellipses (...) |
Caret position
The caret position is also annotated in the far-right side of the vertical scroll bar.
Color | Default annotation | Settings name |
---|---|---|
Dark blue | Overview caret |
Display modes
The scroll bar has two modes: bar mode and map mode.
Bar mode
Bar mode displays annotation indicators on the scroll bar. Clicking on the scroll bar scrolls the page up or down but doesn't jump to that location in the file.
Map mode
Map mode displays lines of code, in miniature, on the scroll bar. You can choose how wide the map column is by selecting a value in Source overview. To enable a larger preview of the code when you rest the pointer on the map, select the Show Preview Tooltip option. Collapsed regions are shaded differently and expand when you double-click them.
Tip
You can turn the miniature code view off in map mode by setting Source overview to Off. If Show Preview Tooltip is selected, you still see a preview of the code at that location when you hover your pointer on the scroll bar, and the cursor still jumps to that location in the file when you click.
The following image shows the search example when map mode is on and the width is set to Medium:
The following image shows the Show Preview Tooltip option:
Tip
To change the colors that you see in map mode, choose Tools > Options > Environment > Fonts and Colors. Next, in Display items, choose any of the items that are preceded with "Overview", make the color changes you want, and then choose OK.