I've searched but didn't find any info on how to disable references (or the codelens completely) in the Visual Studio Code, they're quite useless and annoying for me.
-
1@Louy Google is your friend, but a short description might be that it adds annotations inline with your code, to show you certain details that you might not otherwise see, such as counts of references to properties and fields.– ElkvisSep 14, 2016 at 18:01
-
2I created an extension called Setting Toggle which lets me turn the codeLens on and off easily. My extension also lets you toggle any vs code setting. I found the jumping code when loading C# files very annoying, however the reference count is really helpful sometimes.– user6322327Jun 15, 2018 at 17:07
-
32019 and still codelens is annoying. It would be nice if it was only shown at focus but until then, it looks much better without it.– Spiral OutOct 21, 2019 at 18:08
-
42021 and still codelens is annoying.– outdeadJun 13, 2021 at 16:08
-
4@Elkvis It's 2022 and not only is codelens still annyoing but this page is the top result on Google for "visual studio code disable codelens"– MiffTheFoxMar 7, 2022 at 3:21
9 Answers
You can enable or disable code lense by setting editor.codeLens
to true
or false
in user settings (see https://code.visualstudio.com/Docs/editor/editingevolved#_reference-information for more info).
-
13Latest vscode has a search function in the settings, just type in codelens and uncheck the box.– EdwinNov 15, 2018 at 8:34
-
-
I just right clicked on one of the references in a class and they all went away.– SamApr 22, 2022 at 12:13
-
@Sam Are you saying that you couldn't find menu item
File
-Preferences
-Settings
? Oct 6, 2022 at 10:36
Update: in the new settings editor of VSCode, it's as simple as typing codelens in the search and ticking the first checkbox in the results:
For me, the setting that fixed it was:
"editor.codeLens": false
in my user preferences json file.
-
4Ctrl + , (comma) to quickly open Settings and start searching. For reference for anyone like me who doesn't have it memorized. :) Oct 7, 2021 at 19:18
Step by step:
1- Press CTRL+SHIFT+P and search for "User Settings", and open settings.json file. This file sits under:
%UserProfile%\AppData\Roaming\Code\User\settings.json
2- On right panel override setting "editor.codeLens" with "false" value.
To specifically disable the references in the C# editor, add this to your User Settings:
"csharp.referencesCodeLens.enabled": false
This specifically hides the number of references in the C# editor while keeping the rest of CodeLens' features intact.
MotKohn also pointed out that you can use javascript.referencesCodeLens.enabled
or typescript.referencesCodeLens.enabled
below. Make sure you give them some points if that helped!
I disabled it by going to file | preferences | settings
Finally:
Workspace | Text Editor | (scroll down a little)
For people using any Linux OS:
- Go to
File
>Preferences
>Settings
- Under drop-down
Text Editor
, search forCode Lens
and disable it.
You can do it using a single click on VS Code. Just install the extension Setting Toggle
made by Ho-Wan on VS Code.
Once you install, click on T as shown in the image to toggle Codelens.
-
Looks a bit awkward, but works very well! Upvoting! By default it is setup to toggle Code Lens, so no configuration needed. Bonus: you can now toggle lens from Chift+Ctrl+P by typing
Setting toggle
. Apr 16, 2021 at 13:25 -
This is a great piece of additional information! It doesn't exactly qualify as an answer to the question where it is only asked to permanently disable Code Lens. But for those who want to disable/enable Code Lens on the fly, this is great! Thanks for sharing :)– ADTCNov 26, 2021 at 9:48
Shortcut to toggle this feature on/off quickly: CTRL+SHIFT+P
Toggle TypeLens
-
Please indicate why you are downvoting this answer. It is a valid answer to the question asked. I offered it up as an alternative to workspace/user settings for those interested. Jul 31, 2019 at 19:45
-
This doesn't appear to be a VS Code native feature. Perhaps you are disabling it for the TypeLens extension. You need to mention that in the answer.– ADTCNov 26, 2021 at 9:46
The editor.codeLens
property doesn't seem to work for F#, at least for the inline type-annotation lens. I needed to set:
"FSharp.inlayHints.typeAnnotations": false
to disable it.