Choose folders to be ignored during search in VS C

2020-01-27 09:22发布

Right now when I use +O to search for files, the fuzzy matching appears to operate over all files in the current project. Unfortunately, this includes a number of files from build and vendor directories. So, for instance, if I want to search for all JavaScript files and do +O and type .js in, the file and symbol results include around 1500 hits and all of them except the two ones are complete noise.

Is there a way to specify certain directories to be ignored for purpose of search?

14条回答
Explosion°爆炸
2楼-- · 2020-01-27 09:48

If I understand correctly you want to exclude files from the vscode fuzzy finder. If that is the case, I am guessing the above answers are for older versions of vscode. What worked for me is adding:

"files.exclude": {
    "**/directory-you-want-to-exclude": true,
    "**/.git": true,
    "**/.svn": true,
    "**/.hg": true,
    "**/CVS": true,
    "**/.DS_Store": true
}

to my settings.json. This file can be opened through File>Preferences>Settings

查看更多
疯言疯语
3楼-- · 2020-01-27 09:50

Update April 2018

You can do this in the search section of vscode by pre-fixing an exclamation mark to each folder or file you want to exclude.

enter image description here

查看更多
够拽才男人
4楼-- · 2020-01-27 09:50

Create a file with .gitignore & put the folder or file name which one you want to ignore.

to ignore everything below node_modules folder

echo node_modules/ > .gitignore 
查看更多
Ridiculous、
5楼-- · 2020-01-27 09:50

I wanted to search for the term "Stripe" in all files except those within a plugin ("plugin" folder) or within the files ending in ".bak", ".bak2" or ".log" (this is within the wp-contents folder structure of a wordpress install).

I just wanted to do this search one time and very quickly, so I didn't want to alter the search settings of my environment. Here's how I did it (note the double asteriks for the folder):

  • Search Term: Stripe
  • Include Files: {blank}
  • Exclude Files: *.bak*, *.log, **/plugins/**

Here's what it looked like

查看更多
地球回转人心会变
6楼-- · 2020-01-27 09:52

The short answer is to comma-separate the folders you want to ignore in "files to exclude".

  1. Start workspace wide search: CTRL+SHIFT+f
  2. Expand the global search with the three-dot button
  3. Enter your search term
  4. As an example, in the files to exclude-input field write babel,concat to exclude the folder "babel" and the folder "concat" in the search (make sure the exclude button is enabled).
  5. Press enter to get the results.
查看更多
爷、活的狠高调
7楼-- · 2020-01-27 09:54

Forget aboves for vscode exclude search pattern, try to below pattern it is working for any folder in vscode last version!

!../../../locales/*

for example i have searched like below vscode example clude settings

files to include: *.js

files to exclude: **/node_modules,!../../../locales/,!../../../theme/,!../../admin/client/*

查看更多
登录 后发表回答