When you right-click a file in Visual Studio Code, you have the option 'Find File References.' Is it possible to add a keyboard shortcut to that action? Additionally, I would like to exclude certain folders when the shortcut is used.
I tried adding the following to my keybindings.json
:
{
"key": "ctrl+shift+f",
"command": "editor.action.findFileReference",
"when": "editorTextFocus"
}
However, the command editor.action.findFileReference
doesn't seem to exist. Could it be named differently? I haven't been able to find the correct command.
Also, if it's possible to exclude a folder from the search, it would be helpful. Some folders, like /node_modules
, are quite large and make the command slow. How can I achieve both adding the shortcut and excluding specific folders from the search?
When you right-click a file in Visual Studio Code, you have the option 'Find File References.' Is it possible to add a keyboard shortcut to that action? Additionally, I would like to exclude certain folders when the shortcut is used.
I tried adding the following to my keybindings.json
:
{
"key": "ctrl+shift+f",
"command": "editor.action.findFileReference",
"when": "editorTextFocus"
}
However, the command editor.action.findFileReference
doesn't seem to exist. Could it be named differently? I haven't been able to find the correct command.
Also, if it's possible to exclude a folder from the search, it would be helpful. Some folders, like /node_modules
, are quite large and make the command slow. How can I achieve both adding the shortcut and excluding specific folders from the search?
1 Answer
Reset to default 1The command is extension-specific. The builtin extensions in VS Code provide it for Markdown and TypeScript/JavaScript. For TS/JS, see How to find all references of a selected module in VS Code?. TL;DR: use the typescript.findAllFileReferences
command. For Markdown, use markdown.findAllFileReferences
.
Usage for TS/JS would look like this:
{
"key": "ctrl+b", // TODO: change to whatever you want
"command": "typescript.findAllFileReferences",
"when": "(editorLangId == typescript || editorLangId == javascript)",
},
(No need to specify a file argument because the command itself defaults to the active text editor, and in any case, at the time of this writing, you can't use variable references in keybindings).
Also, if it were possible to exclude a folder from the search, it would be helpful, since some folders, like /node_modules, are quite heavy, which makes the command slow.
You want the search.exclude
setting.