46

I am using vscode, and I would like to exclude some directories (with webpack bundles) from 'go to file' option in vscode.

I tried to exclude them by "search.exclude" and "files.exclude". That worked in files tree and in search, but I still can find these files by 'go to file'.

Do you know how to do this?

2

5 Answers 5

48

As @adamesque stated, to exclude files from quick open you can either add them to files.exclude or search.exclude setting.
The issue then is that Quick Open also stores recent items, even from excluded paths.

Fortunately, VSCode now have a command File: Clear Recently Opened!

EDIT: As I needed to replace a Disk path while keeping my recent files I found where they are stored. It's in the storage.json file which is under /Users/imac/Library/Application Support/Code/storage.json on macOS and AppData\Roaming\Code\storage.json on Windows.

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

1 Comment

If you have a directory with 100k+ files and your Quick Open takes forever to find anything, these options files.exclude and search.exclude will not help you. I added a directory with 100k+ files to both of these options so that it's not visible in the explorer view but the Quick Open is still unusable. The only fix I know is removing the directory from your workspace.
13

I thought I had this exact problem, and all the relevant issues I could find in the VS Code GitHub project seemed to have been fixed (see https://github.com/Microsoft/vscode/issues/19029, https://github.com/Microsoft/vscode/issues/6502).

In my case, because I had previously opened some of the files in those excluded directories, they still showed up in "Go To File" in the "Recently Opened" section, which made me think the exclusion feature wasn't working.

Turns out I just had to manually remove those items from history to keep them from showing up. Open the Command Palette, run Remove from History, and then select the a file to remove. You may need to do this for each file you'd previously opened from an "excluded" dir, but after this is done, they shouldn't show up anymore in the "Go to File" menu.

Hope this helps!

Comments

11

Version 1.44:

now we have an option in the settings.

If you tipe "Goto file" in the setting search bar, the editor opens up a Search:Exclude section, and you can add a folder or files.

enter image description here

Comments

2

enter image description here

CTRL + SHIFT + P, then select File: Clear Recently Opened

Comments

1

As @melMass suggests Clearing history has also the benefit that when you use Go to file (i.e. Ctrl+p) it gives results from your project as well as from history. So a lot of times history contains a file name similar to our project file and you wonder why my code is not working; when in fact you are working in the wrong file.

So clear history as often as you can to avoid this confusion.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.