I am used to Resharper where I can search for files, not the content, but the filename, which makes it quick to open new files.
Is this feature implemented in Visual Studio Code and is there a shortcut for it?
I am used to Resharper where I can search for files, not the content, but the filename, which makes it quick to open new files.
Is this feature implemented in Visual Studio Code and is there a shortcut for it?
Using Go to File... which is under the Go menu or using keyboard shortcut:
Then type the file name.
Also be sure to checkout that you can set your own keybindings and that there are cheatsheets available for Windows, macOS and Linux.
cmd
+ e
searches on the current file, the correct key binding is cmd
+ p
that brings the command palette where you can search for files and much more
cmd
+ p
.
Commented
Jan 24, 2017 at 12:12
Since the 1.70.0 release in July 2022, you can find and filter in tree views such as the Find Explorer. You can press Ctrl+Alt+F inside trees to pop up the Find control.
when you click anywhere in the explorer tree, and start typing something on the keyboard, the search keyword appears in the top right corner of the screen : ("module.ts")
And when you hover over the keyword with the mouse cursor, you can click on "Enable Filter on Type" to filter tree with your search !
CMD/CTRL + F
Commented
Aug 23, 2022 at 13:20
On OSX, for me it's cmd ⌘ + p. cmd ⌘ + e just searches within the currently opened file.
Win: CTRL+P or CTRL+E
Mac: CMD+P or CMD+E
Open the Command Palette:
and hit backspace to delete ">" character and then begin typing to search for files via filename. :)
workbench.action.quickOpen
.You can use this to search the Keyboard Shortcuts
menu located in Preferences
.
On MacOS the default keybinding is cmd ⌘ + P.
(Coming from Sublime Text, I always change this to cmd ⌘ + T)
For filtering in the tree on keyboard typing. The feature is deprecated. No more work.
No more of this old red inflexible box:
Actually not really. It could have been. The new way only filters on expanded folders only. And that's a shame. Check the last session for where the development is at. And for the options we are left with.
https://code.visualstudio.com/updates/v1_70#_tree-find-control
CMD + F
(mac) or CTRL + F
(else) [while focused]
No settings are needed. It just works. And more elegantly (except for the problem of only filtering searching through the visible expanded directories).
And for the default mode. highlight
or filter
. You can change that with:
"workbench.list.defaultFindMode": "highlight"
"workbench.list.defaultFindMode": "filter"
It's great to know about this feature. But then you'll soon encounter the limitation it has at the moment.
Filtering only through open directories. It can help great. But then we want to filter through all. And when the project is big. That becomes totally unusable.
We can see it's added to the backlog here: https://github.com/microsoft/vscode/issues/116286
duplicates: 1
Expand all
Ok what about expanding all. Then using this. ===> That would work great => But => There is no such a feature of expanding all now.
Some configuration
At the moment no configuration does help!
"workbench.list.keyboardNavigation": "filter"
doesn't and many others. I tried them all. For the moment!
Extension that does that probably using web view
None exists. And to be implemented one needs to figure out the indexation used by vscode. Or implement its own indexation and then fuzzy search through using indexes. Otherwise something more simple that works for no big directories. Can be built fast. [I don't have time to do it myself. Especially that this would be resolved sometime in the future and we still can work with CTRL|CMD + P]
So that to clear for you the thoughts that you may get. And save you time.
So shortly we may see the feature of filtering all in a future version of vscode as it was added to the backlog. Right now we will be waiting. And maybe long enough.
Expand all seems not to be coming at any time or any time soon.
The now is => use CTRL|CMD + F on visible things. or on folders. By manually expanding them.
Or use CTRL|CMD + P without closing it. By following the next rules:
Ref: 1
As of now the search and filter in the file explorer are as follows:
Here a preview of the fuzzy search
Otherwise here are some notes on the current state:
Here are some previews that show how, if the project structure is small. You still can find the filtering on the explorer good for many use cases.
- Even if not found, the search in visible only. So you have to check folders
- You can still navigate and filter in such a manner.
- It can still be useful. Depending on your case and the size of the project.
- Specially if you needed to go through project structure.
- Otherwise, the workaround by the command pallet is our best solid tool 🔥.
- In big projects. Or directory it's totally useless.
- (no one wants to play super Mario).
- Once you go through all
- Disable the filtering and u get all expanded
- activate filter again, and filtering go right (already all is expanded)
Also works in ubuntu with Ctrl+E
You can also press F1 to open the Command Palette
and then remove the >
via Backspace. Now you can search for files, too.
The problem with Ctrl+P (or Cmd+P) is that it searches your workspace while ignoring files and folders set in the .gitignore
file. To change this behavior, add "search.useIgnoreFiles": false
in your settings.json
file under .vscode
directory.
NOTE that search.exclude
and files.exclude
settings will override this. So, in your settings.json
file, you should comment them out or set these two settings to false as well if you want to search all the files and directories in your VS Code project. An example for settings.json
where search.exclude
and files.exclude
are commented out for searching all the files:
{
"search.exclude": {
//"**/Lib": true,
//"**/Scripts": true
},
"files.exclude": {
//"**/Lib": true,
//"**/Scripts": true
},
"search.useIgnoreFiles": false
}
Look here for more info.
consider you have thousand of files in vs code and you want to search for a file with particular name then
If you just want to search a single file name
Just Ctrl+P, then type and choose your one
If you want to open all files whose name contains a particular string
Put any common words inside those files
. That's the issue. I'd love to find every file with a certain name.
Commented
Aug 10, 2020 at 17:29
^(?<![\w\W])
to search bar after toggling "Use Regex", this regex matches the start of file, so it will list all files once
To search for specifil file types in visual studio code.
Type ctrl+p and then search for something like *.py.
Simple and easy
If using vscodevim extension, ctrl + p won't work so I saw another answer using:
ctrl + shift + p
which opens the command palette. Hit backspace to remove the '>' and then start typing your filename.
Ok, coming from a big Tmux + Vim user that often wants VSCode to "bend to my will", this is how I looked at it.
CMD+P
is sub-optimal when you have a large workspace. The alternative here is to "use less folders in the VSCode workspace" (since VSCode cries and buckles it's knees trying to index things as they are even added) / "use more workspaces". If you use less folders and files, then CMD+P
fuzzy-search works fineCMD+F
is find IN files, not FOR files. If that's your thing, sure, go for it, but I want to find a file deep in a project quickly and open it up, not drill down 10 levels like a cave man.What I found works best, is this:
CMD + Mouse Click
the file and voila! Pops into the editor.The fact I can't right click or CMD+SHIFT+F
can't just show me files when it even prepends the path for "files to include" and deep searches the files anyway.... is bonkers to me. The find mechanism with CMD+SHIFT+
already has the capability, just show me the FILES, not what's IN the files as an option. 90% of the work is already there.
So TL:DR, if you want to find a file quickly in a folder, just open a terminal, find it, and CMD + <Mouse Click>
.
Check your settings for 'Use Ignore Files' and 'Use Global Ignore Files'. If these are checked, VSCode won't search any folders listed in .gitignore or .ignore
I ended up installing the extension File Name Search. It displays in the side navigation bar all files that match a name part, so I can open them one by one to check them or process them.
Here is a demo of a search in explorer followed by a search in the Filename search extension:
With VSCode 1.75 (Jan 2023), you will have a new file filter option: a 'Fuzzy Match
' toggle.
That comes from issue 116286: Tree: Support continuous find
In a list of files I can filter them by start typing the name of the file. It is a super useful feature when you have hundreds+ files.
My issue is that the filter is trying to find the letters in the whole file name.
Here is an example search for word "file":this-is-**file**-i-looked-for.jpeg (I expect this to be returned) **f**or-th**i**s-**l**.jp**e**g (This should not be returned, it is only a random match)
Would it be possible to add there extra settings to only returns full strings matches? Or is there some setting already buried somewhere?
Solution: adding a 'Fuzzy Match
' toggle button to the tree find widget.
New options:
defaultFindMatchTypeSettingKey.fuzzy
: Use fuzzy matching when searching.defaultFindMatchTypeSettingKey.contiguous
': Use contiguous matching when searching.Use right arrow key!
Opens files in tabs, without closing current search!!!
⌘+p |
🔎 |
⬆️ / ⬇️ |
➡️ |
cmd + p
Type name of file you're searching for
Use up/down arrows to highlight file you want to open
Use right arrow key to open highlighted file in new tab