Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

There's no way to exclude paths from a search #149

Closed
mattbasta opened this issue Mar 7, 2014 · 109 comments · Fixed by atom/scandal#17
Closed

There's no way to exclude paths from a search #149

mattbasta opened this issue Mar 7, 2014 · 109 comments · Fixed by atom/scandal#17

Comments

@mattbasta
Copy link

When searching, filters can be specified. However, there's no way to exclude paths from the search.

E.g.: *.js, -*.min.js cannot be used to exclude minified files from a search of JS

@benogle
Copy link
Contributor

benogle commented Mar 7, 2014

You can try the ! char. We use minimatch.

@TrevorSayre
Copy link

Something like *.js, !*.min.js does not work
Using just !*.min.js actually only searches .min.js files (inverse of what you might expect)
Unsure how to search *.js files but not *.min.js files

@dbkaplun
Copy link

Searching for require in !node_modules/* returns no results. Am I doing it wrong?

@jaikdean
Copy link

jaikdean commented Apr 8, 2014

I am seeing the same buggy behaviour. If I do a search for something with the path pattern of "!directory/to/ignore" it search only in that directory rather than ignoring it and searching everything else.

@noahrc
Copy link

noahrc commented Apr 10, 2014

'!' also doesn't exclude a file or directory for me, and using it multiple times makes no difference.

@probablycorey probablycorey self-assigned this Apr 10, 2014
@probablycorey
Copy link

Using the ! syntax to negate a search won't work right now. The problem is from this line https://github.com/atom/scandal/blob/master/src/path-filter.coffee#L47.

But I don't see a solution around it other than fixing how scandal handles directory/file filtering.

@probablycorey
Copy link

Moving from bug to enhancement.

@TrevorSayre
Copy link

TextMate just added this feature on 2014-04-18 (v2.0-alpha.9539), so it may be useful to have as a reference:
textmate/textmate@v2.0-alpha.9533...v2.0-alpha.9539
textmate/textmate@45481d2
textmate/textmate@9524439

They describe their method as follows:

In file pattern globs the tilde () and bang (!) operators both indicate that what follows must not
match the file path. For example: .{c,h}~vendor/* will match .c and .h files except when under
the vendor/ directory. It’s possible to specify multiple exclusion patterns and also to start the pattern
with the exclude operator, e.g. !build/!cache/ will match anything not in build/ or cache/. If the
operator is used inside brace expansion (e.g. {Icon\r,*
.nib}) then it’ll be treated as a literal match,
similarly when used last in the pattern (e.g. *.txt~).

@dbkaplun

This comment has been minimized.

@philipgiuliani
Copy link

👍 Its a really important feature because it finds about 1000 results in my log/ directory when i search something and so the search gets reaaalllyy slow...

@kwerle
Copy link

kwerle commented Aug 1, 2014

This is [now] marked as an enhancement, but with the horrible results from logfiles and the like, find is barely usable. Please consider this a bug.

@m3kka

This comment has been minimized.

@acusti
Copy link

acusti commented Aug 22, 2014

Exclusions for Find in Project is definitely a big deal. In web dev, just being able to !bower_components,!node_modules in the File/directory pattern field would feel like :godmode:

@tregusti
Copy link

Exclusions for Find in Project is definitely a big deal. In web dev, just being able to !bower_components, !node_modules in the File/directory pattern field would feel like :godmode:

I second this, I too get 1000+ results here that make a search replace impossible to do.

@mattbasta
Copy link
Author

This issue is one of only a small handful of things blocking me from using Atom. If I can't filter out the vendor/ or node_modules/ directories in my projects, it's impossible for me to search in any meaningful way.

@rodrigoAbril

This comment has been minimized.

@mattvagni
Copy link

I think this should be addressed by: atom/scandal#17

Unless anyone knows why atom currently disables negation?

@vincentcr
Copy link

The issue is not fixed, because it only works with file patterns. For example, trying !node_modules has no effect

@nicolas-van
Copy link

My case is quite simple, in 1.0.7 I have this:

atom.config.get('core.ignoredNames')
[".git", ".hg", ".svn", ".DS_Store", "._*", "Thumbs.db"]
atom.config.get('core.excludeVcsIgnoredPaths')
true

And yet when I make a search in my project I can find results in my .git folder.

@cluxter
Copy link

cluxter commented Sep 2, 2015

Not working for me in Atom v1.0.10 in Windows 7.
Here is the result of the commands in the console:

atom.config.get('core.ignoredNames')
[".git", ".meteor", ".semantic-ui", ".git\", ".git/"]
atom.config.get('core.excludeVcsIgnoredPaths')
true

Yet when I right-click on my project root folder, click on "Search in Directory" and search a word, results from ".git" folder are shown.

However it works when I add this in the "File/Directory pattern":

!.git/

Am I doing it wrong or is it a bug? I tried everythink I could, including modifying the "config.cson" file and adding the "exclusions" line. Nothing worked.

EDIT: my goal is to avoid writing the !.git/ filter everytime. That's all.

@MichaelJCole
Copy link

I just edited my config and got something like this to work. I added an ignoredNames section to my config.cson (Preferences -> Open Config Folder -> config.cson):

"*":
  core:
    autoHideMenuBar: true
    ignoredNames: [
      ".meteor"
      ".git"
      "etc"
    ]

and don't get results in these directories:

/etc/*
/src/.git/*
/src/admin/.meteor/*

Not saying there isn't a bug, but this worked for me on 1.0.7 on Linux Mint

@TerrenceLJones
Copy link

@MichaelJCole This works for me as well on 1.0.15 on Mac O.S.

@jagc
Copy link

jagc commented Oct 2, 2015

@MichaelJCole Thanks!! Worked for me.

Atom.io: 1.0.19
OS: Windows 7 Ultimate SP1 64bit

Would be great though if we have an option where we could input a list of directories of where (and not) to search.

@Sam-Gram
Copy link

Sam-Gram commented Oct 9, 2015

Just use commas and start the path from the root project directory. Works well.

@PierBover
Copy link

Is there a way a exclude files from the command "find file"?

I've added .jpg, .png in the ignored names setting but they do still appear there.

Edit: So *.jpg, *.png did it.

@CharlesMcKeever
Copy link

Bless you @MichaelJCole Works for me on 1.0.19 on OS X El Capitan. You are awesome!

@chung-leong
Copy link

Feature is still buggy in 1.1.0. A file can still pop up if the path matches the file/directory pattern. I.e. If you do "Search in directory", files in ignored folders will show up (and promptly crashes the editor).

@benogle
Copy link
Contributor

benogle commented Nov 9, 2015

If you do "Search in directory", files in ignored folders will show up

Can you make a new issue giving the exact values you have in each text box + if possible, a test repo? I know it will do this in some case due to some ambiguity.

@proehlen
Copy link

@MichaelJCole Thanks so much for that man. Works well and removes a major frustration with Atom for me.

@jldec
Copy link

jldec commented Dec 14, 2015

@benogle see #621

@kevin-smets
Copy link

@MichaelJCole thanks for that quick fix. I added 2 project which led to 2 million files being indexed, it was crazy...

Imho it should be as easy as right clicking on a folder - exclude from index or something, where you could then take just that specific folder, or use it as a pattern.

@leongaban
Copy link

Ok I finally got this working, had to add .sass-cache into my config.cson file, now when I fuzzy search I don't get .scssc files

 core:
    closeEmptyWindows: false
    ignoredNames: [
      ".scssc"
      ".sass-cache"
      ".git"
      ".hg"
      ".svn"
      ".DS_Store"
      "Thumbs.db"
      "node_modules"
    ]
    themes: [
      "atom-material-ui"
      "atom-material-syntax"
    ]

@ghost
Copy link

ghost commented Feb 26, 2016

+1 @MichaelJCole @leongaban
Your config.cson hack worked for me.

Trying to exclude paths by typing them in the search does not work for me.
Trying to exclude paths using .gitignore (with "Ignore VCS" enabled in Prefs) does not work either.

@konstantinmagg
Copy link

+1 Would be great to ignore folters (e.g. 'bower_components' or 'node_modules') in the search bar.

@leongaban your solution worked for me, too. thx ;)

@ocssor
Copy link

ocssor commented Mar 2, 2016

Right Click Folder -> Search in directory

Still searches in '.svn' despite that being in ignored names (both in core settings view and in config.cson).

@akmur
Copy link

akmur commented Mar 2, 2016

Thanks @leongaban

@MichaelJCole
Copy link

FYI, this bug is closed. Posting here doesn't help fix your issue, and emails a bunch of people who can't help. For best results, please open a new bug. Thanks!

@MohammedAl-Mahdawi
Copy link

In order to search in a folder within my project folder and ignore the .git folder within it, I did the following
selection_108
Just added , !.git after my folder path.

@stringaro-leo
Copy link

stringaro-leo commented Jan 25, 2017

this works for me: !**/node_modules/**,!**/bower_components/**

@findsje
Copy link

findsje commented Apr 10, 2017

Thanks, this worked for me. Was giving up on this! **/*.html was what I needed.

@eugenealegiojo
Copy link

Nice! This works for me as well: !*.min.js

@mrahulreddy
Copy link

This works for me
!node_modules

@jorgeorpinel
Copy link

jorgeorpinel commented Mar 6, 2018

Not working at all for me ): The "Exclude VCS Ignored Paths" option also not working.

image

@jrial
Copy link

jrial commented Jul 13, 2018

@jorgeorpinel could it be that your file was not saved at that time? If so, see #647

luzpaz added a commit to luzpaz/find-and-replace that referenced this issue Jul 27, 2018
Educate the user on how atom excludes files/directories in the placeholder text directly. I discovered this by searching the issue queue.  
Ref: atom#149
@ghost
Copy link

ghost commented Jun 17, 2019

Just ran into this issue myself. I wanted to find all instances of a keyword within a directory, but wanted to exclude the search from a single nested directory within.

Demo File Structure:

project-name/
    search-this-directory/
        ...
        ...
        ...
        exclude-this-directory/
            ...
            ...
            ...

File/Directory Search Pattern - FAILS

project-name/search-this-directory, !project-name/search-this-directory/exclude-this-directory, 

After several attempts, I found that each additional file/directory pattern built on the previous... Therefore, in order to ignore the nested directory, we simply ignore that one single directory after defining the search context.

File/Directory Search Pattern - WORKS

project-name/search-this-directory, !exclude-this-directory, 

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.