简体   繁体   中英

How to disable codelens in VS code?

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.

您可以通过在用户设置中设置editor.codeLens来启用或禁用代码镜头(有关更多信息,请参阅https://code.visualstudio.com/Docs/editor/editingevolved#_reference-information )。

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.

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

CTRL+SHIFT+P

2- On right panel override setting " editor.codeLens " with "false" value.

editor.codeLens

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 file | preferences | settings

文件首选项设置

Finally:

Workspace | Text Editor | (scroll down a little)

在此处输入图片说明

For people using any Linux OS :

  1. Go to File > Preferences > Settings
  2. Under drop-down Text Editor , search for Code 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.

在此处输入图片说明

快速打开/关闭此功能的快捷方式: CTRL+SHIFT+P Toggle TypeLens

You can Toggle CodeLens with the vscode-togglecodelens extension :

  1. Install vscode-togglecodelens extension
  2. Reload Visual Studio Code
  3. In Visual Studio Code command pallette, type "Toggle Codelens" to make Codelens appear or disappear

Gif: Toggle CodeLens without modifying settings files

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM