How do I show reference count in Visual Studio Code?

前端 未结 5 924
无人及你
无人及你 2021-02-02 07:47

I want to show references count in Visual Studio Code. How can I do it?

相关标签:
5条回答
  • 2021-02-02 08:08

    Visual Studio Code version 1.28.2:

    You need to add this to User Settings:

    Menu FilePreferencesSettings:

    "typescript.referencesCodeLens.enabled": true,
    
    0 讨论(0)
  • 2021-02-02 08:09

    The menu structure ususally changes during years. So in VSCode v.1.43 please follow the next steps:

    1. Click Gear icon and go to Settings

    1. In the "Settings" window in the input field type "reference", click "User" tab, under "Extensions" click "Typescript" and find "Reference Code Lens" checkboxes for javascript/typescript.

    Checking/unchecking checkboxes will automatically apply your changes.

    0 讨论(0)
  • 2021-02-02 08:13

    In Visual Studio 2019 Community it's in Tools → Options → Text Editor → All Languages → CodeLens.

    0 讨论(0)
  • 2021-02-02 08:24

    Sometimes you don't want to turn it on/off completely, but toggle it on/off with a keyboard shortcut. If so, the following may help:

    1. Install an extension: https://marketplace.visualstudio.com/items?itemName=rebornix.toggle

    2. and configure it for your desires. (Preferences -> Keyboard Shortcuts -> keybindings.json)

    For Example for TypeScript:

    {
        "key": "F4",
        "command": "toggle",
        "when": "editorTextFocus",
        "args": {
            "id": "myChosenIdWhatEverItIs",
            "value": [
                {
                  "typescript.referencesCodeLens.enabled": true,
                },
                {
                  "typescript.referencesCodeLens.enabled": false,
                }
            ]
        }
    }
    
    0 讨论(0)
  • 2021-02-02 08:29

    This feature is called CodeLens.

    In Visual Studio find it in menu OptionsText EditorAll languagesCodeLens.

    And in Visual Studio Code it is in menu FilePreferencesSettings → "editor.codeLens": true

    0 讨论(0)
提交回复
热议问题