Visual Studio 2013 Preview: CodeLens aka Code Information Indicators

[Updated: 7/12/2013: Thanks to John Gardner for the updated info.]


There is only one way to describe this next feature: IT ROCKS!


To use this feature you will need Visual Studio 2013 Preview and Team Foundation Server 2013 Preview as some information comes from TFS.



Presenting the Problem

For me, this is the signature feature in Visual Studio 2013. It’s well thought out and solves multiple issues we face as developers. But what IS it exactly? The best way to demonstrate it is to remind you what life was like before we had it. Here is a method (from the TailSpin toys sample code) the way we have seen it in the past:

5-16-2012 6-04-11 PM


What if I need to find all the references to this method? I can press SHIFT+F12 and get results in the Find Symbol Results window:

5-16-2012 6-09-48 PM


How about the tests associated with this method? I’d either dig through the references above or dig into the Test Explorer window and see what I can find. But what if I want to know who last changed this method? How about the number of times this code has changed? Now I have to dig into other windows to locate the data. In short, I can get all the information I need but have to go to several different places to get it.



Solving the Problem

The Visual Studio team has come up with an elegant solution to the problem: show information about the code WITH the code. It’s a great addition to the development experience. Originally called Code Information Indicators, the marketing folks have now dubbed this CodeLens.


Turning It On

CodeLens is on by default but I want to point out the information you can choose to view. Go to Tools | Options | Text Editor | All Languages | Code Information Indicators:

5-16-2012 6-29-59 PM

(NOTE: a faster way to get here is to press CTRL+Q for QuickLaunch and type the word “information” into the search area then select the Code Information Indicators entry)


I’ll show these in the order you will most likely see them when you begin using this feature.




Show References

5-16-2012 6-38-10 PM

The first indicator you will typically notice is the references. This is just like using Find All References but instead of presenting the information in another window a summary of references is shown with the code. With any of the CodeLens indicators you can access the details in a couple of ways.



Mouse Access

You can click on any indicator to see the results:

5-16-2012 6-56-14 PM


Also there is a scroll bar (if needed) to allow moving through multiple entries:

5-16-2012 6-57-02 PM



Keyboard Access

If you don’t want to take your hands off the keyboard, you can simply hold down your ALT key on your keyboard and each indicator will show a number above it:

5-16-2012 7-02-04 PM


Pressing ALT + [indicator number] will show the information within. In this example, ALT+2 will open the references. These numbers are static so you can always depend on them. Regardless of where you are, ALT+2 will always show the references.




Show Tested By

With any method we often want to know what tests are associated with it. The Show Tested By option will show what tests are associated with your code and an overall status indicator:

5-16-2012 7-35-20 PM


As you can see in this example, the tests haven’t been run yet as shown by the icon to the left of the test summary. If I click on the Show Tested By section or press ALT+3:

5-16-2012 7-42-07 PM


Then I get the information window:

5-16-2012 7-49-55 PM


Notice we can run the currently selected test or run all tests. To access the Run All or Run links with just your keyboard just use your TAB key. If you want to examine an individual test method you can press Enter (or Double Click) any entry in the information window and the editor will show the test method details:

5-16-2012 8-02-04 PM


Let’s jump back to our original code. Looking at the Show Tested By indicator we can see that if all the tests have passed this is the result:

5-16-2012 8-06-05 PM


If any tests fail, then we will see something like this:

5-16-2012 8-10-03 PM


You can see any tests that failed by opening the Show Tested By area:

5-16-2012 8-11-33 PM




Show Test Status

Now let’s discuss the Show Test Status indicator. Normally, when we look at a test method this is what we see:

5-16-2012 8-22-36 PM


However, once we run our tests, it would be nice to see the status of the run with the test method itself. This is where Show Test Status comes in. By turning this on we can see the status of the last run represented as an icon (to the left of the references information):

5-16-2012 8-27-31 PM


If you want to see the latest test result, you can Click the icon or press ALT+1:

5-16-2012 8-29-33 PM


And see the test result window:

5-16-2012 8-34-24 PM




Show Authors and Show Changes

The Show Authors and Show Changes options actually show the same information but filter it in two ways. Both are updated when you Get Latest from source control. Show Authors will show the name of the last person to make a change plus a count of any other unique individuals who have worked with the same code:

5-16-2012 9-04-43 PM


Whereas Show Changes will show the total number of changes in the code’s history:

5-16-2012 9-14-16 PM


Selecting either of these by using your mouse or by pressing ALT+4 and ALT+5 respectively:

5-16-2012 9-17-18 PM


Opening either one of these indicators will reveal the following:

5-16-2012 9-19-59 PM


This is where things get interesting. You can Right Click any entry in this window to be presented with three options that we will examine in detail:

5-16-2012 9-24-40 PM



View Diff Of Changeset[Number]

This will show the difference between the selected changeset and the one prior for comparison:

5-16-2012 9-29-10 PM



Changeset Details

This choice will show the details of the changeset in Team Explorer:

5-16-2012 9-30-39 PM



Send Email To [Author]

Pretty self-explanatory, this option will open up your default email program and allow you to begin crafting an email to the author of the changeset with a link to remind the author of the code changed:

5-16-2012 9-34-22 PM 





In this section I’ll show some additional items that may be of interest to you as you discover more about CodeLens.


Navigating Between Information Windows

Once you have opened any information window:

5-16-2012 12-04-12 PM


You can use RIGHT ARROW or LEFT ARROW to move between the other information windows.

(NOTE: The team that works on this let me know that the official keyboard shortcut for moving between these windows is ALT+RIGHT ARROW and ALT+LEFT ARROW. Be aware that just plain ARROW keys may stop working in future iterations of the build and you will need to use the official keys to move between windows here.)



Skipping Lines

I began this article saying that this feature is well thought out. Nothing emphasizes my point more than the way the indicator are treated in the editor. Rather than being intrusive and even throwing off your line counts by treating the indicators as a line of code the indicators are simply decorations added in the editor and are not counted as an actual line:

5-16-2012 10-14-49 PM


The concept of being non-intrusive is so ingrained into this feature that even the cursor will skip over it when you are using your keyboard to move between lines in the editor.



Changing Indicator Fonts and Colors

If you want to modify the font and/or color of the indicators you can go to Tools | Options | Environment | Fonts and Colors then select Show Settings For the Code Information Indicators:

5-16-2012 9-54-27 PM


Experiment with these to find settings that are appealing to you.



Turning It Off

If, for some reason, you don’t like this feature then you can always turn it off by going to Tools | Options | Text Editor | All Languages | Code Information Indicators and disable the feature.





CodeLens is truly an epic addition to the Visual Studio world. I am a huge fan of this feature. Try it yourself and tell me what you think! 🙂

Comments (31)

  1. That is indeed pretty nice! Going to try it out tonight I think!

  2. zainnab says:

    Hey Marcus 🙂

    Yeah this is one feature everyone should try out. I think this is a major improvement for Visual Studio developers.


  3. Byron Adams says:

    Should always say which edition these features are in. Sad to see it is not in Pro. or Premium.

  4. zainnab says:

    Bryon 🙂

    For the preview items I don't normally deal with editions since the location of features can change before RTM and features can (and often are) moved around. With that said, this is currently slated for Ultimate. That may change but even if it doesn't the only argument I've ever heard against Ultimate is around pricing. The additional cost can be easily justified when you combine features like IntelliTrace and, now, CodeLens together. If you are getting push back from your managers that the value isn't there then loop me into the conversation ( and I'll be happy to help justify the value proposition.


  5. Randy P says:

    Hey Zain, awesome post. Yep, Code Lens does rock!  Thanks for the deep explanation of this features. I'm going to run out and try it now. 🙂

  6. Adam Hill says:

    I would really like a "Show Authors and Changes" for the code. Where the method changes in the editor as I do a ALT+<n>. And I see the code changes and the authors name.

  7. Marcel says:

    I love this feature. It should definitely be in Premium. Everybody can benefit from this, not just the big companies with Ultimate!

  8. zainnab says:

    Hey Marcel 🙂

    We have companies of all sizes using Ultimate so it is definitely for everyone. See my comment above if you have having issues getting your management to switch to Ultimate and I am happy to get engaged in the conversation.


  9. Jm says:

    I would love more information on persuading management to get ultimate.  It seems like a REALLY tall order when you're looking at $10k per desktop.

  10. zainnab says:

    Hey Jm 🙂

    Let's do it! Shoot me an email and we can set something up. It takes a about an hour to an hour and and a half with demos and other evidence I present. Each conversation is unique based on the business so I'll need about thirty minutes with you first to understand your business a little better since some Ultimate features are more important than others to an organization.


  11. Ben says:

    Loved it until I released it requires VS Ultimate, no way the small company I work for could ever justify a spend of more than £13k per developer!

    This needs making available in other versions of VS, even if its an extra feature pack you have to buy.  

  12. zainnab says:


    See my comments above. I can't make any guarantees but I'm happy to get involved in conversations with management. Your argument, for me at least, seems to be logically problematic. If we move a feature from Ultimate to Premium then why not move it from Premium to Professional? Why not from Professional to Express(Free)? Although you didn't say it, I've actually had a few people tell me we should give Ultimate away for free. My response is always the same: Would you, as a software developer, agree to work at your company for free? Regardless how you spin it, you work for money. You have to pay rent/mortgage, buy a car, and many other things that require you have an income.

    We have many teams at Microsoft that work on Visual Studio. They devote their careers to making a great product and, like you, they need to eat, buy a car, and pay rent/mortgage. They spend a large amount of time deciding where features will land in order to best serve our customers. I personally think they do a great job at balancing features across the product lines while considering the company's financial needs. These are just my thoughts on the subject but I would ask that you keep this in mind when requesting features be moved or product be given away for free.


  13. Ivan says:

    The idea is awesome, but I'm not happy with current implementation and turned it off. Namely, it looks very unusual for me when lines of code have different heights because of code indicators. I used to certain look & feel of the editor and addition of these indicators doesn't look like 'non-intrusive' for me.

  14. zainnab says:

    Hey Ivan 🙂

    I could see that. I think it's kind of like the MS Office Ribbon when it first came out. It's cool but takes a little getting used to as well. I also know there are some enhancements slated for this feature.


  15. Mike Gromer says:

    I've been loving the CodeLens feature of the preview.  I'd love to see integration with git for the Authors and Changes lenses.

  16. Bob says:

    If I'm using TFS in the cloud ( with a Git repository…will I be able to see code changes in codelens?  I migrated my git repo over to TFS in the cloud and figured I'd fire up VS2013 against it to see this in action and was sad to not see any changes marked…though I understand why if that's not supported

    Just curious if I'm missing some setting to index or something on the repo itself to get this working =)

  17. zainnab says:

    Hey Bob 🙂

    To my knowledge we haven't integrated it with Git yet. I suspect we will at some point but only after we get the feature set nailed down with our source control first.


  18. says:

    It doesn't seem to work with my C++ and C++/CLI code. Supported?

    For my small bit of C# it's only showing References. Can we configure it to pull revision/author information from the integrated SCC? (Perforce in my case)

  19. inVINCEble says:

    I'm getting an interesting problem after I installed Visual Studio 2013 RC.  In the CodeLens section, I can no longer uncheck just the "Show References" by itselft.  I have to turn all of CodeLens off.  In Visual Studio 2013 Preview, I was able to turn this one feature off but seems like I can no longer do this.  Do you know if there's a reason for this?

  20. says:

    Wow- Ultimate only – that's a real kick in the teeth for me. I have 1 ultimate, 2 premiums and several Pros. My Premium and Pro devs are now treated like 2nd class citizens – maybe Ill drop this whole MSDN thing at next renewal.

  21. Drazen Dotlic says:

    Just like many others, I'd like to point out that usability of this feature will somewhat hinge on its accessibility.

    Seeing how Ultimate is prohibitively expensive for most small(ish) companies which usually buy just one or two Ultimate licenses for their architects, the rest of the crew getting Premium (at best) or Professional (most often it appears), I don't see this getting used much.

    And please could we stop with the bullsh*t argument of Microsoft devs have to eat. I am quite sure that you do not live off of MSDN subscriptions, but from Windows sales, which in turn get boosted by the applications availability. Cheaper Visual Studio (or free), more applications will be available for Windows, hence more money for Microsoft (so that you can eat and pay mortgage).

    Just look at other platforms (ahem, Apple with MacOSX to lesser extent and iOS to a much bigger extent) – how much do their tools cost? Nothing.

  22. zainnab says:

    jschroedl 🙂

    I the feature doesn't work with C++ / C++ CLI in the RC. I haven't tested the RTM bits yet but suspect the C++ integration will come at a later date TBD.


  23. zainnab says:

    Adam / Drazen,

    I've put my thoughts out there and my offer stands to help internalize this with your management if necessary. I believe my points are valid and I agree with the decision to put CodeLens in Ultimate. If you know me then you know I am highly critical of the VS team at times but this is not one of those times. I consider CodeLens to be one of the most well thought out features I have seen in Visual Studio.


  24. Ivan Z. says:

    Interesting feature. Is it possible to extend CodeLens indicators by third-party extension? Source control for example.

  25. Steve H says:

    It's very cool, something this valuable to developers should be included in all versions of VS, besides ultimate already has a list of features not offered in the other versions.  And it's only a matter of time someone will write a free extension that might not be as powerful but be very useful with ref counts ect..

  26. JeffreyKey says:


    Just want to offer another viewpoint on the Ultimate decision: Like a lot of small companies out there, our competition is *not* on the Microsoft platform. By putting features like these out of reach of small companies like ours, you're making us less productive against not only our competition, but yours too. Microsoft makes money by selling the platform. Every customer we sell to runs Windows, SQL Server, etc. Our software gives them the motivation to buy into the platform. Visual Studio licenses likely make up an infinitesimal percentage of overall revenue, while at the same time making the majority of the people that write software for your platform less productive than they can be.

    I have ten people on my team. According to pricing at the Microsoft Store, that would be $132,990 to get Code Lens. I could buy licenses for third-party tools that have equivalent Ultimate functionality and still have $100,000 left over.

    With the world having moved to the web and in the process of embracing mobile, it's in your best interest to give the people still interested in the Microsoft platform the best tools possible. Keeping Ultimate out of the hands of the people that advocate for your platform serves no one.

  27. zainnab says:

    Hey Jeffrey 🙂

    While I stick by my original reasons for thinking CodeLens should stay in Ultimate, I do see your point. One of the things I would personally love to see is a flattening of the SKU mix so that, maybe, Professional goes away and Premium/Ultimate go down in price to compensate. I have never been a fan of the Pro SKU anyway and I think it would make buying decisions easier. Just my .02


  28. Catto says:

    Hey Now Zain;

    Code Lens sure is a neat slick feature. As always thank for all the info you've provided.



  29. Mark M says:

    I can't believe that people really like this feature.  It clutters up the code, making it much harder to read.  I don't want random non-fucntional text scattered throughout what I am working on.  If it were hidden but activated through a keyboard shortcut (like intellisense is) then it would be fine, but as it is currently implemented it is just intrusive.  I am glad this article includes instructions on turning it off.

  30. Sergey Klepikov says:

    For some reason on my project it shows as "-references".

    I did try it on the very simple test project and it is works fine there.

    Wandering fi there is something is off on my "big" project

  31. Shivprasad says:

    Love Code lens. The best part is while coding itself you get a idea of what impact your code can have on other entities. I have termed the codelens usefulness as

    LIT :- L for Latest changes , I for impact analysis and T for Testing.

    Here is a video which i have uploaded on youtube for the same

Skip to main content