In my work with C# in Visual Studio Code, I found the “Reference code lens” feature to be somewhat distracting. The reference numbers that appear above methods and properties can clutter the editor, especially when working with large files. If you’re like me and prefer a cleaner, less noisy environment, youβll want to know how to turn this feature off. Fortunately, disabling it is quick and easy, and Iβll walk you through it.
Thank me by sharing on Twitter π
Why Remove the Reference Code Lens?
By default, Visual Studio Code shows a “Reference code lens” that indicates how many times a method, class, or property is referenced in the code. While useful in some scenarios, this can become distracting when you’re focusing on the logic and structure of your code rather than its references. Turning off the code lens cleans up the interface, letting you focus better on your work.
If you ever need the reference count again, it’s just a few settings clicks away.
How to Disable the Reference Code Lens in VSCode
Hereβs how you can easily turn off the reference code lens for C#:
- Open the Settings
First, pressCtrl + ,
(orCmd + ,
on macOS) to open the settings panel. ![Open Settings Screenshot] - Search for “Reference code lens”
In the search bar at the top, type “Reference code lens”. This will bring up the relevant setting. ![Search for Reference Code Lens Screenshot] - Disable the Code Lens
Youβll find a checkbox labeled Reference Code Lens under the.NET
section. Simply uncheck it to disable the feature. Alternatively, if you prefer using thesettings.json
file directly, hereβs what youβll need to add or modify:
{
"dotnet.codeLens.enableReferencesCodeLens": false
}
And that’s it! With this setting turned off, your editor will no longer display reference counts, giving you a cleaner, more focused workspace.
etguuds USB to USB C Cable 3ft, 2-Pack USB A to Type C Charger Cord Fast Charging for Samsung Galaxy A15 A25 A35 A55 A54, S24 S23 S22 S21 S20 S10 S10E, Note 20 10, Moto G, for iPhone 16 15, Gray
$6.99 (as of December 21, 2024 08:38 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)COLORCORAL Cleaning Gel Universal Dust Cleaner for PC Keyboard Car Detailing Office Electronics Laptop Dusting Kit Computer Dust Remover, Stocking Stuffers for Men Women Kids Teens 160g
$6.98 (as of December 21, 2024 08:38 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Apple USB-C Woven Charge Cable (1 m) βββββββ
$15.00 (as of December 21, 2024 08:38 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Conclusion
Disabling the reference code lens in VSCode is a simple tweak that can significantly reduce visual clutter when working on C#. By following the steps above, you can streamline your coding environment and bring more focus to the tasks at hand. Whenever you need the reference counts back, it’s just a quick settings change away.