56

I have a project with a lot of files and folders. There are no problems with finding files. They can be found with Ctrl-P. But there are many folders in which files with the same name are made. Therefore, it is easier to search for a file by the name of the folder in which it is located. How in VS Code to search for folders in the current open project?

For example, I have the following project structure:

A/ main.js B/ main.js ... Z/ main.js 

The file main.js from the folder P will be easier to find by the folder name.

4
  • 1
    Open issue: github.com/Microsoft/vscode/issues/30404 - they suggest typing "P main" Commented Aug 20, 2018 at 21:21
  • 1
    If what you want is filter folders in the project explorer, that's not possible. Using ctrl+P (or cmd+P) is however an easy way to do this. Simply put /myfolder or folder/file or even folder/*/file. You'll see files contained by that folder and the full path so.. like finding the folder. Commented Sep 21, 2018 at 16:52
  • Wish they had something like IntelliJ does. Add a trailing slash and it searches for folders (when searching for files in the popup). Commented Apr 30, 2022 at 22:05
  • @pank i came here looking for the same. Seems like the feature-request has mutated : github.com/microsoft/vscode/issues/27317... You can use P or use the incorporated terminal in the meantime. Commented May 10, 2022 at 5:39

9 Answers 9

32

While using Ctrl-P, you can type the full path of the file, so if i have two files named bar you can search on Ctrl-P with "foo/bar" or with "qux/bar" Vscode uses fuzzy search (like so many others), so you don't have to actually type the whole thing. There is no way, to my knowledge and research, to find and be directed to a specific directory.

Sign up to request clarification or add additional context in comments.

Comments

11

You can simply select a folder on the explorer and tape some filter keywords.

Recently, vscode added a shortcut, if you are using a recent release just typing won't work, first tape ctrl + f.

enter image description here

Comments

9

Ctrl + Shift + E

and start typing. You'll see your search on the top right corner of file explorer.

By default it does not filter by result but your focus will jumps to the first one. From there you can Enter to open it.

If you want to show only results containing the string of search : click on filter icon next to your search (state will be remembered).

Echap

to exit/remove search or

Ctrl + Shift + E

again to switch back focus to last place you were typing.

1 Comment

Great tip! One note, I am on Mac, for me, Space key opened the folder, not Enter. Referring to "From there you can Enter to open it."
5

This VSCode extension does exactly what you're asking for.

https://marketplace.visualstudio.com/items?itemName=rwu823.open-folder

1 Comment

This seems to open all the files in a matched folder. I'd prefer just to display it in the Explorer view
5

It's called Advanced tree navigation, You can filter the currently visible files in the Explorer view. With the focus on the Explorer view, press Ctrl+Alt+F (Cmd+Alt+F on macOS) to open the Find control and type part of the file name you want to match.

See more in VSCode docs - Advanced tree navigation

Example

3 Comments

I've over written the shortcut. What's the original command for this action?
Thank you, this is a life saver. I wish this were in the command pallette so it were more discoverable, too.
Yes but this only filters/searches for file names, not folder names. At work, the main directory I work in has over one thousand repository folders in it, so it would be extremely helpful to be able to filter/search by folder name specifically, not file name
2

The Search Folders extension is perfect for this:

  1. Install the extension: Search Folders.
  2. Open the Command Palette (Ctrl + Shift + P) and type "search-folders".
  3. Enter the folder name, press Enter, and it will focus on the folder in the file explorer.

Comments

1

I found a way to search through subfolders. Click on a folder you wish to search, than / and start typing for a name of subfolder

Comments

-2

It's simple. Just open the parent folder of your folder in VSCode. Then right-click on the folder you want to find subfolder in and choose "Find in folder"

1 Comment

the thing is we want to look for folder name. not the file in folder
-2

Click on any file/folder in the explorer. Then press Ctrl + F. A search bar will come up in the explorer and you can search for the file you want.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.