如何在VS代码中禁用CodeLens?

我已经搜索过了,但没有找到任何关于如何在VisualStudio代码中禁用引用(或完全禁用代码)的信息,它们对我来说非常无用和烦人。

135045 次浏览

您可以通过在用户设置中将editor.codeLens设置为truefalse来启用或禁用代码透镜(有关详细信息,请参阅https://code.visualstudio.com/docs/editor/editingevolved#_reference-information)。

更新:在VSCode的新设置编辑器中,只需在搜索中键入CodeLens并勾选结果中的第一个复选框即可:

enter image description here


对我来说,修复它的设置是:

"editor.codeLens": false

在我的用户首选项JSON文件中。

一步一步:

1-按Ctrl+Shift+P并搜索“用户设置”,然后打开settings.JSON文件。 此文件位于:

%UserProfile%\AppData\Roaming\Code\User\settings.json

CTRL+SHIFT+P

2-在右侧面板上,用“假”值覆盖设置“编辑器.codelens ”。

editor.codeLens

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

要在C#编辑器中明确禁用引用,请将以下内容添加到用户设置中:

"csharp.referencesCodeLens.enabled": false

这特别隐藏了C#编辑器中的引用数量,同时保持CodeLens的其余特性不变。

莫特科恩还指出,可以使用下面的javascript.referencesCodeLens.enabledtypescript.referencesCodeLens.enabled。如果有帮助的话,一定要给他们一些分数!

我通过file | preferences | settings禁用了它。

file preferences settings

最后:

Workspace | Text Editor | (scroll down a little)

enter image description here

对于使用任何Linux操作系统的人:

  1. 进入File>Preferences>Settings
  2. 下拉Text Editor下,搜索Code Lens并禁用 它.
只需单击VS代码即可

完成。只需在VS代码上安装Ho-Wan制作的扩展Setting Toggle。 安装后,单击测试(如图所示)以切换CodeLens.

enter image description here

editor.codeLens属性似乎不适用于F#,至少不适用于内联类型注释透镜。我需要设置:

"FSharp.inlayHints.typeAnnotations": false

使其失效。