"Find All References" across files for a method/function in VSCode is not possible - visual-studio-code

Visual Studio Code version 1.27.2
Find all References only list references in the current file.
I need to find all references across files in a project.
Is it possible ?
Something like find usages
If you right click a symbol and select "find usages". If the current symbol is a function, then "find usages" searches for all places where this function is called. If the current symbol is a variable, then "find usages" searches for all places where this variable is used etc etc.

Advanced features such as Find all references are implemented by each language extension.
For JavaScript, try creating a jsconfig.json at the root of your workspace with the contents:
{
"compilerOptions": {
"target": "ES6"
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}
This file tells VS Code to treat all JS files in your workspace as part of the same javascript project. Find all references still may not work properly in JavaScript if your code is too dynamic. It works best against modern js that uses import/export, class, and friends

In Visual Studio Code you can do this by first highlighting the text you want to search for, then using the command: CTRL + SHIFT + F (pressing all at once).
CTRL + SHIFT + F is just a shortcut for accessing the search tab on the left-hand side of VSCode. Hope that helps and apologies for the scribbles :)

Right-click on the variable and choose Find All References
This is how it looks in VSCode
My About Visual Studio Code Info:
Version: 1.47.2
Commit: 17299e413d5590b14ab0340ea477cdd86ff13daf
Date: 2020-07-15T18:18:50.054Z (5 days ago)
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 18.6.0

Related

Is there a way to set default file type as "all files" for vscode on windows?

I am running vscode on windows 10.
Version: 1.40.2 (system setup)
Commit: f359dd69833dd8800b54d458f6d37ab7c78df520
Date: 2019-11-25T14:54:45.096Z
Electron: 6.1.5
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Windows_NT x64 10.0.17134
each time I save a new file, vscode consider it as a plain text by default.
this post gives an approach to set the defalut language.
question
is there a way to set default file type as "all files"?
Not an answer (yet)
I have the same issue where an "unknown" file extension causes the VSCode Save as file chooser dialog on Windows defaults to Plain Text(*.txt;*.gitignore), regardless of Language Mode (e.g. Plain Text, also HTML) and then always appends ".txt" to the filename, requiring fiddling with the dropdown to set the file type to All Files (*.*).
While it seems possible to set the default language and setup custom file type associations (e.g. Visual Studio Code save language mode (override default), https://code.visualstudio.com/docs/languages/overview#_common-questions) I have not been successful in affecting the Save As Dialog in any way (even with manually setting the language).
A quick glance at
https://github.com/microsoft/vscode/blob/master/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.ts#L281 (which may be the completely wrong place) caused me to try
"files.associations": {
"*.ext": "*"
}
and
"files.associations": {
"*.ext": ""
}
but that did not change anything for me (except breaking the syntax highlighting of at least the settings.json).
Feel free to update this with further information..

How to enable Reference Search View extension

Today in my colleague's vscode I saw that finding references opens in sidebar.
I searched the web and I understood that it's done by Reference Search View, an extension shipped by vscode but it's not working for me. How can I enable it?
Version: 1.30.2
Commit: 61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8
Date: 2019-01-07T22:49:48.319Z
Electron: 2.0.12
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
OS: Linux x64 4.15.0-43-generic
This is a built-in extensions. It is included in VS Code 1.30+ and is enabled by default. Search #builtin references in the extension view to make sure you have not accidentally disabled it.
To show references, run the References: Find all references command. This should open the references sidebar with the reference results
Fixed!
The issue was that I was using
"command": editor.action.referenceSearch.trigger"
instead of
"command": "references-view.find"
in my keybindings.
I'm actually pleased! because I can still have the old behaviour by using the first command :)

VS Code Go to Matching Pair Command

This command won't work for me. I had installed the Visual Studio Keymap, but when I uninstalled that it made no difference. If I open Keyboard Shortcuts and try customizing it to some other keybinding, still nothing. I open the simplest javascript folder/file (folder with a single .js file) to test, simply putting the cursor on either side of the parens in console.log('hi');
Version is 1.28.2 (latest). The only other extensions I have installed are Debugger for Chrome & ESLint.
editor.action.jumpToBracket is what you want for .js files, Ctrl-Shift-\.
The "Go to matching pair" command: editor.emmet.action.matchTag is for html files.

Visual Studio code shortcut to find classes and methods?

Is there a shortcut in Visual studio Code (Or an extension for it)?.
I use to use PHPstorm, there was a function that you can find the classes directly, by clicking on it. When I use visual studio code you need to search all files.
shortcut: ctrl + p
This will behave just like the 'double-spacebar' of JetBrains products.
This should work with the PHP IntelliSense extension:
PHP 7 installation is required.
https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-intellisense

"Open containing folder" hotkey in Visual Studio 2012

In versions of Visual Studio before 2012, I was able to create a hotkey to perform "Open Containing Folder" for the current active text file. I accomplished this by creating a macro that had a keystroke assigned to it.
Visual Studio 2012 does not have macros. How would I accomplish the above in this version?
Unfortunately you'll now need to download the VSSDK and create a VSPackage to do that, now that macros have been dropped from the IDE.
The closest thing to a macro now is a PowerShell script, which you could run from the console but I'm not aware of any way to assign a keyboard shortcut to it.
Running PS outside of the IDE is an option (via an External Tool command with a keyboard shortcut configured), but obtaining the EnvDTE outside of process could be complicated.
EDIT: There is a much simpler solution. I can't believe I didn't realise it to begin with!
Simply go into Tools... Options... Environment... Keyboard locate File.OpenContainingFolder and assign a shortcut. This command will open the active document's containing folder.
I found a keyboard shortcut for Open Containing Folder: Alt + - + O
When you press Alt + - it opens Tab Context Menu Then you see that the shortcut key for Open Containing Folder is O key, then you should press O.