331

I recently installed Visual Studio 2013 Ultimate. Now, as you know, there is this "n references" above all methods.

When I go to the CodeLens options, I can't disable this single feature, since the checkbox is grayed out.

Options for enabling specific Code Lenses

So how can I disable it?

0

4 Answers 4

162

Only workaround I found was un-checking the "enable codelens" option.

3
  • 3
    Apparently, that's also the only way to undock a window after it's been docked. Turning off CodeLens resets the popup windows. Maddening. Your tip saved some of my sanity.
    – Suncat2000
    Commented Nov 18, 2019 at 22:42
  • You also can make a button that automates this but it requires that you install an extension: stackoverflow.com/questions/31746690/…
    – krowe
    Commented Dec 18, 2021 at 11:48
  • @Suncat2000 I searched for "lense" to fix this... didn't find it because it's spelt "CodeLens"... wow
    – PandaWood
    Commented Feb 7, 2023 at 3:59
44

The References indicator is required to be on because it is the only one that knows how to do "placeholder" items (the one that says "- references"), and is guaranteed to show up everywhere that codelens appears.

If you could turn off references, then it is highly possible that codelens would reserve space for indicators, and yet no indicators would ever appear, so you would end up with blank lines on every method/class/property that aren't real blank lines, they're just reserved space for codesense elements that will never appear.

I'd suggest using the "send a frown" thing in visual studio and commenting about this if you want to turn just references off.

2
  • 15
    I had to turn CodeLens completely off to unclutter my interface. I couldn't find the "send a frown" thing, if anybody has a suggestion where to look. But I thought I'd leave this comment in case anybody from Microsoft comes along. IMHO clutter is undesirable and you could have that same information in a rollover popup.
    – Code Dude
    Commented Dec 20, 2018 at 20:07
  • I am starting to see a new implementation of CodeLens for JavaScript files now - which is very distracting. I disabled the JavaScript CodeLens, but still have the spaces over the lines where the reference counts would be. Feel free to upvote the issue I created to help bring it to Microsoft's attention: developercommunity.visualstudio.com/t/…? Commented Jun 7, 2023 at 16:47
27

If you want to keep the CodeLens functionality but mostly get rid of the references, go to:

  • Options/Environment/Fonts and Colors
  • Show settings for: CodeLens

and change the settings to:

  • Font: Consolas
  • Font Size: 6
  • Indicator Text: White
  • Indicator Text (Disabled): White
  • Indicator Separator: White

Choosing Consolas reduces the line height beyond the default Calibri font, even at font size 6. There might even be a smaller font that you can use but I haven't found it.

If you have a dark background choose a matching dark color instead of White where it is mentioned in the steps above, since the goal is to hide the CodeLense text.

4
  • 2
    I tried this but it still leaves my attributes floating weirdly above my method names. Commented Mar 9, 2016 at 19:14
  • 1
    Yeah, it's a compromise. I was getting more distracted by having a line of text above every method signature, so this just makes the inline CodeLens text blend into the background (until you hover over it). You could always make the text some really light color instead of White, so that it stands out a tiny bit. Commented Mar 10, 2016 at 18:54
  • It might be worth mentioning, for those of us on the dark side (using a dark theme), that to "hide" the text the chosen color should match the background. (White text with the dark theme has rather opposite the intended effect.)
    – JYelton
    Commented May 11, 2017 at 18:37
  • Lucida Console at 7px is height-wise narrower and more Readable than calibri 8px (vs2019 default) at laptop screen. i coundnt read Consolas-6px. but this post show a better way
    – bh_earth0
    Commented Jun 11, 2021 at 9:27
19

In Visual Studio 2015. Tools > Options. Text Editor > All Languages > CodeLens. Uncheck “Enable CodeLens”

1
  • Still the only option to reduce the clutter and embrace the Zen. It also moved text around, which isn't appreciated (by me). And in code review, testing, and similar situations, it's very clear that it's missing if you turn it off completely, which is good. Commented May 27, 2022 at 15:10

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