共用方式為


Visual Studio 2013 Preview: Enhanced Scroll Bar

Visual Studio 2013 has another great new feature: enhanced scroll bar functionality. The new scroll bar will show cursor location, breakpoints, and much more! Let’s take a look.

5-17-2012 12-51-16 PM

 

 

Power Tools

Before we begin I want to address where some of the new features in VS2013 are coming from. In Visual Studio 2013 many of the new features we put into the product were actually introduced via the Productivity Power Tools for Visual Studio 2012. This is an ongoing trend and you will see that many of the new features from future versions will come directly from the Power Tools. If you are still on 2012 you can get a lot of the newest functionality by installing the Visual Studio 2012 Power Tools which can be found here:

https://visualstudiogallery.msdn.microsoft.com/3a96a4dc-ba9c-4589-92c5-640e07332afd

 

 

Scroll Bar Options

To really get a handle on the new scroll bar functionality the first thing you should do is Right Click on the vertical scroll bar and choose Scroll Bar Options:

5-17-2012 11-57-37 AM

 

You will see several settings that can be modified:

5-17-2012 12-00-10 PM

(NOTE: You can also get to this area by going to Tools | Options | Text Editor | All Languages | Scroll Bars)

 

 

Show Scroll Bar

5-17-2012 12-08-43 PM

The first two options are pretty self-explanatory they will allow you to show or hide the scroll bars. For the most part you will leave these checked unless you have some special reason not to have them visible. 

 

Display

5-17-2012 12-12-18 PM

The Display area allows you to turn on annotations that will show special items throughout the entire document within the scroll bar. This allows you, at a glance, to see where things like breakpoints and bookmarks are. We will look at these in the order you are most likely to encounter them but here is an example of the vertical scroll bar with annotations in it:

5-17-2012 12-32-50 PM

 

 

Show Caret Position

5-17-2012 12-17-37 PM

The first annotation you will most likely encounter is the caret position indicator. It simply shows the current position of the cursor with a blue line in the scroll bar.

 

 

Show Changes

5-17-2012 12-28-50 PM

If you missed my blog post a couple of years ago on tracking changes in the editor, this is a good time to read it. You can find the post here:

https://blogs.msdn.com/b/zainnab/archive/2010/04/14/track-changes-in-the-editor-vstipedit0048.aspx

 

The Show Changes option simply shows the changes within it so you can see modifications at a glance for the entire document.

 

 

Show Marks

This options is fairly broad and covers several types of marks that can appear in code. Most notably this will show breakpoints:

5-17-2012 12-42-29 PM

 

Additionally, this will also show things like Bookmarks:

5-17-2012 12-44-01 PM

 

 

Show Errors

The final indicator is arguably one of the most important. It shows any syntax errors the editor is aware of:

5-17-2012 12-46-58 PM

 

This let’s you quickly see where there are errors that need to be fixed before you compile your code.

 

 

Behavior

There are two behavior options for the vertical scroll bar: bar mode and map mode. So far everything we have seen is the traditional bar mode for the scroll bar. Now we will switch to map mode:

5-17-2012 12-55-12 PM

 

Map mode essentially turns your vertical scroll bar from this:

5-17-2012 12-56-48 PM

 

To this:

5-17-2012 12-57-38 PM

 

 

Source Overview

Map mode is miniature look at your document so you can quickly get a feel for your code. There are four options for source overview when using map mode. I’ll show examples of the four views below. Of these the Off setting will be the most confusing until you see the Preview Tooltip in action so be patient.

 

Wide

5-17-2012 12-57-38 PM

 

Medium

5-17-2012 12-59-53 PM

 

Narrow

5-17-2012 1-00-50 PM

 

Off

5-17-2012 1-02-23 PM

 

 

Preview Tooltip

Regardless of which map mode view you use there is also an option to have the Preview Tooltip. Simply put your mouse pointer over any part of the vertical scroll bar and you will get a preview of the code at that position in the document:

5-17-2012 1-09-33 PM

 

Annotations

All annotations previously mentioned also show up in map mode:

5-17-2012 1-12-45 PM

 

 

Go to a Specific Location on the Scroll Bar

You basically have two options when you want to go to a specific location on the scroll bar. Let’s examine both ways.

 

Left Click

As long as you are in map mode:

5-17-2012 2-39-51 AM

 

You can simply LEFT CLICK any area on the scroll bar and you will jump to that location:

5-17-2012 2-41-10 AM

 

For this reason, I suggest, even if you don’t want the map, that you at least use map mode set to Off to get this functionality so you can quickly move around using the scroll bar:

5-17-2012 2-44-42 AM

 

 

Scroll Here

Now that you have a solid base level of knowledge for this feature there is one more important item I want to show you: Scroll Here. If you find any place that is interesting to you in the vertical scroll bar and want to quickly go to that location you can simply Right Click the location and choose Scroll Here:

5-17-2012 10-12-17 PM

 

The new location will come into view so you can begin looking at the code:

5-17-2012 10-13-50 PM

 

 

Finally

The enhanced vertical scroll bar is a great tool for developers to quickly see places of interest and to examine those locations. Try this feature out and see if you like it as much as I do. :)

Comments

  • Anonymous
    July 02, 2013
    Nice! It's going to be very interesting to find out how (if?) I'll be using the Source Overview in the future.

  • Anonymous
    July 02, 2013
    Yeah Marcus give it a shot! I think you'll like it. :) Z

  • Anonymous
    July 08, 2013
    Well this is great. I have recently started coding in C# (from VB) and I still feel lost in all the braces. Hopefully the map mode and the preview tool tip will help in making me feel "in control" of code again.

  • Anonymous
    July 08, 2013
    It's always strange when you first come over from VB but give it some time and you'll get used to it :)

  • Anonymous
    July 08, 2013
    Thanks for useful feature! " you can simply Right Click the location and choose Scroll Here:" You can simply Left Click the location.

  • Anonymous
    July 08, 2013
    Ivan :) left clicking the scroll bar does a Page Down or Page Up operation. You can easily test this by scrolling to the top of a large document and then clicking at the bottom of the scroll bar. It will not go to the location you clicked but instead simply Page Down from the current location. Z

  • Anonymous
    July 14, 2013
    Ivan :) I stand corrected on this one. Looks like the Page Up / Page Down behavior for the vertical scroll bar is still there when not in map mode but they have added the ability to click on a location when you ARE in map mode and it will jump to the location you clicked. I've updated the post to reflect this new ability. Z

  • Anonymous
    September 06, 2013
    Every time I set the option for map mode (either directly through Tools or through the context menu), the scroll bar appears, but only for the current document. If I switch documents it is gone, and when I return it is still gone. Cannot get the scroll bar to stay in map mode no matter what I try.

  • Anonymous
    January 14, 2014
    How can you change the background color of the enhanced scroll bar, like you could with the old power tolls version in 2012, thanks!

  • Anonymous
    January 21, 2014
    TheAgent; there is a new option which is "Auto Brace Completion" in the new IDE so we no need to worry on the count of braces :-)

  • Anonymous
    February 24, 2014
    Colors are found in options - Fonts and Colors 4 different item prefixed with overview Took me a while to figure out

  • Anonymous
    February 24, 2014
    What is missing compared to the Productivity Power Tools is the option to show all highlighted occurrences in a file. A feature I use often.

  • Anonymous
    June 15, 2014
    In this vertical scroll bar, I also see the size of the method being displayed. And I am not sure where to set it on or off. Any ideas?

  • Anonymous
    June 26, 2014
    When I hit a break point, the indents disappear.  How to turn that off?  

  • Anonymous
    July 31, 2014
    The right click "Scroll Here" is great but there is a fundamental bug in it's operations. It doesn't scroll to where you actually "Right Clicked on the Scroll Bar", it scrolls to where you "Left Click" on the "Scroll Here" menu item, So if you try and scroll to a point near the bottom of long code, the menu and "Scroll Here" will be above your cursor and that is where you will be sent to.  Has anyone seen this mentioned or a fix for this yet. The Map mode is a nice workaround for the moment.

  • Anonymous
    August 15, 2014
    But how do you change the COLORS of the things in the scroll bar.  Namely, the contrast between the grey scroll bar and the light grey of what section of the page I am currently looking at is so light that I can't see it half the time, and I can't find the right setting to change under "Environment > Fonts and Colors".

  • Anonymous
    January 21, 2015
    HI, Great idea for a tool but why can i only see some lines in the minimap? Is there someway to change this behaviour. Right now the minimap is'nt showing a helpful version of my code and i am not helped navigation-wise. Best regards Pierre

  • Anonymous
    March 20, 2015
    The comment has been removed

  • Anonymous
    April 23, 2015
    when click on the vertical scroll bar I would really like the "scroll" to be disabled - it should jump to the clicked location. scroll simply takes too long and feels unresponsive.