How do I show reference count in Visual Studio Code?

Visual Studio-Code

Visual Studio-Code Problem Overview


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

Enter image description here

Visual Studio-Code Solutions


Solution 1 - Visual Studio-Code

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

Solution 2 - Visual Studio-Code

Visual Studio Code version 1.28.2:

You need to add this to User Settings:

Menu FilePreferencesSettings:

"typescript.referencesCodeLens.enabled": true,

Solution 3 - Visual Studio-Code

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

enter image description here

  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.

enter image description here

Checking/unchecking checkboxes will automatically apply your changes.

Solution 4 - Visual Studio-Code

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,
            }
        ]
    }
}

Solution 5 - Visual Studio-Code

The simple process for show the reference count.

  1. Step 1: From Settings – Type CodeLens and Enable the Editor: Code Lens and JavaScript > References Code Lens to check the references in JavaScript File.

enter image description here

  1. Step 2: Then open any of your JavaScript file to identify the References of Property or Method in the file.

enter image description here

  • If any case, you can't show the reference, then enable(yes) assets to build and debug in own project.

enter image description here

  • If you'll click to the yes button of assets then, you'll seen the .vscode file

enter image description here

Solution 6 - Visual Studio-Code

On Visual Studio 2019 Community Edition, just hit Ctrl+Q or look for the text box next to Help, enter CodeLens there. That is by far the quickest and easiest.

CodeLens on Search Enable

Solution 7 - Visual Studio-Code

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLointView Question on Stackoverflow
Solution 1 - Visual Studio-CodeAliView Answer on Stackoverflow
Solution 2 - Visual Studio-CodeM. ChristensenView Answer on Stackoverflow
Solution 3 - Visual Studio-CodeRuslan KorkinView Answer on Stackoverflow
Solution 4 - Visual Studio-CodeLonelyView Answer on Stackoverflow
Solution 5 - Visual Studio-CodeVijay KumavatView Answer on Stackoverflow
Solution 6 - Visual Studio-CodeHeinz09View Answer on Stackoverflow
Solution 7 - Visual Studio-CodeBob MolloyView Answer on Stackoverflow