I want to show references count in Visual Studio Code. How can I do it?
Visual Studio Code version 1.28.2:
You need to add this to User Settings:
Menu File → Preferences → Settings:
"typescript.referencesCodeLens.enabled": true,
The menu structure ususally changes during years.
So in VSCode
v.1.43 please follow the next steps:
Gear icon
and go to Settings
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.
In Visual Studio 2019 Community it's in Tools → Options → Text Editor → All Languages → CodeLens.
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:
Install an extension: https://marketplace.visualstudio.com/items?itemName=rebornix.toggle
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,
}
]
}
}
This feature is called CodeLens.
In Visual Studio find it in menu Options → Text Editor → All languages → CodeLens.
And in Visual Studio Code it is in menu File → Preferences → Settings → "editor.codeLens": true