754

Visual Studio 2013 introduced a new feature where it shows you how many times each of your methods are used.

I don't find it very useful, and it messes up the spacing of my file. How do I disable it? Can't seem to find the option.

mpen
  • 272,448
  • 266
  • 850
  • 1,236
  • 11
    @Ouadie: You're allowed to like it. XIII (rightfully) already edited out the bias from my question :-) The only numbers I care about are "0" and "1+". IntelliJ will underline your method to tell you it's unused (if it's private, anyway). I'd much prefer that over the odd spacing this creates, particularly when there are attributes above. – mpen Nov 12 '13 at 07:17
  • 23
    I find the feature quite nice. But I get quite sensitive about white-space in my code which makes it extremely distracting. Ideally it would be possible to replace it with a little dot like a breakpoint in the margin... – AndyM Jan 20 '14 at 20:28
  • 1
    If I knew it's named `Code Lens` I would search it in `Quick Launch`, but I didn't, thanks for the question and including reference count int the title ;) – VahidNaderi Apr 05 '14 at 09:06
  • @VahidND Yeah, I didn't know what it was called either. I didn't have "Code Lens" in the original title, someone edited that in; it's a good thing they didn't take out the 'reference counts' bit. – mpen Apr 05 '14 at 18:34
  • 17
    I specifically came here to find out the exact opposite of this... but this works too. – misterManager Apr 10 '14 at 13:17
  • 25
    Editing someone else's question to "remove bias" is hypocritical and censorship. Don't do it. – Glenn Maynard May 18 '14 at 16:02
  • 2
    what a shame that this isn't in pro. MS seems to really try to alienate themselves. "hey guys! check out this cool thing i made. oh, you can't afford it, but come look anyway." – Anthony Aug 21 '14 at 03:32
  • 2
    Actually it shows more stuff than "n references", it is a lot of quicker version of "find usage" feature but its real power comes when you use version control. You can immediately see who had worked on this class and its methods, and see how many changes are there and inspect them without messing with history and annotate. It supports TFS and Git. – Furkan Omay Jan 09 '15 at 14:24
  • This feature affects both line spacing and editor performance. It is a little bit faster without Cod Lens. – GSoft Consulting Jan 27 '15 at 02:28
  • 9
    This is in VS 2015 Professional. Shame it isn't in the left-hand column though, it's a bit distracting. Like Mark said only 0 and +1 (or even just 0) is relevant. – Rob L Jul 23 '15 at 03:59
  • 1
    I don't really mind the spacing as much as the fade effect. There's a split second where I see an extra blank line which I am tempted to delete. I would like to see an option to remove the fade effect so there is no amount of time where I can see an extra blank line- I would want the codelens text to appear instantly. – TTT Nov 17 '15 at 20:20
  • I would find it VERY useful if the reference counts were correct, but they are NOT. If you call a method from a Razor view, for instance, it doesn't seem to know about this. It also has no idea about calls from outside the project. This might be reasonable, but it's deceptive to say 0 references when there are good reasons why it might not really be 0. – Joshua Frank Dec 15 '15 at 18:14
  • last point of https://blogs.msdn.microsoft.com/visualstudioalm/2014/05/23/code-lens-for-git-in-visual-studio-2013-ultimate-update-3/ – amit jha Jun 07 '16 at 02:02
  • last point of https://blogs.msdn.microsoft.com/visualstudioalm/2014/03/03/new-codelens-indicatorincoming-changes/ – amit jha Jun 07 '16 at 08:35
  • The difference between 1 and 2+ is useful as it would mark it as a potential lambda. – Novaterata Oct 19 '16 at 13:24
  • 1
    Does this answer your question? [How to turn off CodeLens-References](https://stackoverflow.com/questions/20457796/how-to-turn-off-codelens-references) – Superole Dec 17 '19 at 08:23
  • in vscode you type this in settings.json `"csharp.referencesCodeLens.enabled": false,` – STEEL Jul 03 '21 at 17:35

5 Answers5

850

I guess you probably are running the preview of VS2013 Ultimate, because it is not present in my professional preview. But looking online I found that the feature is called Code Information Indicators or CodeLens, and can be located under

Tools → Options → Text Editor → All Languages → CodeLens

(for RC/final version)

or

Tools → Options → Text Editor → All Languages → Code Information Indicators

(for preview version)

That was according to this link. It seems to be pretty well hidden.

In Visual Studio 2013 RTM, you can also get to the CodeLens options by right clicking the indicators themselves in the editor:

editor options

documented in the Q&A section of the msdn CodeLens documentation

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Mark Hall
  • 53,938
  • 9
  • 94
  • 111
  • 10
    That would be it! Just a note to anyone else who might be reading this: unchecking "Show References" alone will not get rid of the giant gap where the "references" text normally is. Unchecking "Enable Code Information Indicators" *does* get rid of the gap, however. – mpen Jul 25 '13 at 03:26
  • 41
    In the RC of VS2013 Ultimate, "Code Information Indicators" has been renamed to "CodeLens". Annoyingly, it seems that "Show References" cannot be disabled for All Languages (in my installation, at least). – alastairs Sep 29 '13 at 13:53
  • 6
    What I would prefer, is the ability to just hide the '0 references' indicators, that would reduce unnecessary repetition. Anybody know if that is possible? – GONeale Oct 28 '13 at 00:51
  • 4
    Note the CodeLens feature is currently only available in the Ultimate edition of Visual Studio. – drobison Sep 03 '14 at 23:46
  • @drobison that is correct , and is why I worded the start of my answer like I did. I only have vs professional. – Mark Hall Sep 03 '14 at 23:49
  • Best option for me would be to consider comment and attribute so to place the codelens above them – SkyG Oct 03 '14 at 09:21
  • 1
    Couldn't find that option. Just turned the whole thing off. – Tawani Nov 22 '14 at 19:27
  • 8
    For what it's worth, this is now in VS2015 Pro, and the right-click behavior is the same. However, it looks like you can't turn off References separate from the rest of the CodeLens display. – Bobson Aug 10 '15 at 03:29
  • Yes, just got it on my new machine with VS2015 Pro installed. Interestingly though I didn't get it on VS2015 Community at home. I thought that was meant to be Pro just licensed differently. I will have to check if the option is there just not turned on by default. – RosieC Dec 01 '15 at 14:11
  • As far as I can tell this option is not available in VS2015 Community, even though Community is supposedly the same as Pro, just licensed differently. – RosieC Dec 10 '15 at 12:14
  • @RosieC You are correct Code Lens is not part of the community edition see feature comparison here https://www.visualstudio.com/en-us/products/compare-visual-studio-2015-products-vs.aspx – Mark Hall Dec 16 '15 at 05:02
  • 1
    @MarkHall thanks for that comparision. I didn't like CodeLens initially because it messes up my white space. I wish it was positioned differently. However I've turned it back on recently and I'm finding it pretty useful, especially test results and the ability to launch tests from the test, rather than having to find it in the test explorer. I've not yet missed it as such on my projects at home (community edition) but then they are a lot smaller projects than the stuff I do at work in pro. – RosieC Dec 24 '15 at 10:09
  • 1
    Thank you, I hate that stuff on there by default.. silly – Maccurt Oct 14 '16 at 18:17
  • Vote this up: https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/18755269-code-lens-seems-useful-but-the-way-it-messes-up-vi – thecoolmacdude Oct 19 '17 at 18:59
  • 1
    Its 2018 and why is this option not switched off by default. – Jayamohan May 28 '18 at 01:09
  • It is so sad that I have to turn off this feature, just because is not quite fast as expected. it takes too long to show the # of references, and another amount of time to load those references. Also when # references is loaded, it will re-process after scrolling or doing other silly action. – Jaider Jun 08 '18 at 21:57
  • the feature is cool; then would better being located in the hover panel; so then clicking to select these features; – H3sDW11e Feb 02 '20 at 21:17
106

Another option is to use mouse, right click on "x reference". Context menu "CodeLens Options" will appear, saving all the navigation headache.

Sean Feldman
  • 23,443
  • 7
  • 55
  • 80
  • Nice solution. Too bad that I tried it before reading this answer and no context menu appeared (the editor was responsive otherwise). But after reading the answer, it worked. Go figure :) – Stefan Monov Jul 18 '16 at 15:10
21

Workaround....

In VS 2015 Professional (and probably other versions). Go to Tools / Options / Environment / Fonts and Colours. In the "Show Settings For" drop-down, select "CodeLens" Choose the smallest font you can find e.g. Calibri 6. Change the foreground colour to your editor foreground colour (say "White") Click OK.

Rob L
  • 2,124
  • 3
  • 22
  • 50
  • 6
    that's thinking outside the box and being creative! :) – Mark Hall Jul 24 '15 at 14:47
  • 1
    @MarkHall but doesn't stop code lens from using my CPU. – Gqqnbig Dec 30 '16 at 01:19
  • 4
    @LoveRight Understand, the question was about getting rid of the added space that code lens added not about CPU usuage if that is an issue then disable it. – Mark Hall Jan 09 '17 at 19:27
  • 1
    Cool. That even has a "feature" highlight references on hover and hide otherwise. – Saulius Jan 11 '18 at 06:29
  • "Courier New @ 6" is even smaller. It turns it from second guessing if you have a double newline there into this (maybe nice I guess) airy layout around functtions. – Luc Bloom Jun 28 '21 at 11:02
20

The other features of CodeLens like: Show Bugs, Show Test Status, etc (other than Show Reference) might be useful.

However, if the only way to disable Show References is to disable CodeLens altogether.

Then, I guess I could do just that.

Furthermore, I would do like I always have, 'right-click on a member and choose Find all References or Ctrl+K, R'

If I wanted to know what references the member -- I too like not having any extra information crammed into my code, like extra white-space.

In short, uncheck Codelens...

JYelton
  • 35,664
  • 27
  • 132
  • 191
NeoH4x0r
  • 311
  • 2
  • 6
  • 7
    Yes indeed, for codelens in my 2017 Visual Studio, the ability to disable just the reference count feature is itself disabled, so I also have to just entirely disable all of codelens. Bummer that I won't get to learn about the other features... but I just can't deal with the look of stuff interleaved with my code. – Mark Seagoe May 06 '18 at 15:43
13

In VSCode for Mac (0.10.6) I opened "Preferences -> User Settings" and placed the following code in the settings.json file

enter image description here

"editor.referenceInfos": false

enter image description here

User and Workspace Settings

Christian Strang
  • 8,470
  • 5
  • 42
  • 53
  • 6
    Thanks for your answer, but this question was about Visual Studio; your answer pertains to VS Code which is an entirely different program. You're welcome to open a new question and answer it yourself if there isn't already one out there. – mpen Jan 18 '16 at 16:27
  • 1
    @mpen ah sorry about that, I was searching for an answer for vscode about this topic and google linked me here. – Christian Strang Jan 18 '16 at 16:34
  • 5
    That's one of the reasons I think MS chose a poor name for their new editor. It's way to similar and doesn't have any relationship AFAIK. – mpen Jan 18 '16 at 16:36
  • I can't find `editor.referenceInfos` in setting of visual studio code. – Loint Aug 03 '17 at 16:56
  • 1
    `editor.referenceInfos` appears to be been renamed `editor.codeLens`. [Source](https://github.com/Microsoft/vscode/issues/17452#issuecomment-267899887) – Jeff K. May 17 '18 at 06:34