753

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.

17
  • 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, 2013 at 7: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, 2014 at 20:28
  • 17
    I specifically came here to find out the exact opposite of this... but this works too. Apr 10, 2014 at 13:17
  • 25
    Editing someone else's question to "remove bias" is hypocritical and censorship. Don't do it. May 18, 2014 at 16:02
  • 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, 2015 at 3:59

5 Answers 5

847

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

17
  • 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, 2013 at 3: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, 2013 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, 2013 at 0:51
  • 4
    Note the CodeLens feature is currently only available in the Ultimate edition of Visual Studio.
    – drobison
    Sep 3, 2014 at 23:46
  • 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, 2015 at 3:29
105

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

1
  • 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 :) Jul 18, 2016 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.

5
  • 6
    that's thinking outside the box and being creative! :)
    – Mark Hall
    Jul 24, 2015 at 14:47
  • 1
    @MarkHall but doesn't stop code lens from using my CPU.
    – Gqqnbig
    Dec 30, 2016 at 1: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 9, 2017 at 19:27
  • 1
    Cool. That even has a "feature" highlight references on hover and hide otherwise.
    – Saulius
    Jan 11, 2018 at 6: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, 2021 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...

1
  • 6
    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. May 6, 2018 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

5
  • 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, 2016 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. Jan 18, 2016 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, 2016 at 16:36
  • I can't find editor.referenceInfos in setting of visual studio code.
    – Loint
    Aug 3, 2017 at 16:56
  • 1
    editor.referenceInfos appears to be been renamed editor.codeLens. Source
    – Jeff K.
    May 17, 2018 at 6:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.