Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude folder in project root (only) #1115

Closed
franciscolourenco opened this issue Feb 22, 2016 · 18 comments
Closed

Exclude folder in project root (only) #1115

franciscolourenco opened this issue Feb 22, 2016 · 18 comments

Comments

@franciscolourenco
Copy link

The objective is to be able to exclude /myproject/node_modules but not /myproject/src/node_modules

One way to achieve this is to specify the project root name in the exclude patern: *myproject/node_modules*. However it doesn't work for every project, because the name of the project changes.

What is being requested is a way to match only folders in the project root, either via proper regex support, or by variable substitution ("$project_name/node_modules"), or simply with "/node_modules/*" which currently doesn't match anything).

People requesting something similar :

@titoBouzout
Copy link
Collaborator

You may can exclude with "/node_modules/**"

@franciscolourenco
Copy link
Author

The example that you game doesn't work for me. Does it work for you? To which setting are you adding the pattern? I'm trying to exclude from project root, not filesystem root.

@titoBouzout
Copy link
Collaborator

OK, I understand can I ask whats the goal? Hide from sidebar or exclude from search and indexes?

@franciscolourenco
Copy link
Author

Exclude from search and indexes. It works but it excludes all node_modules inside the projects, not only the one in the root.

@titoBouzout
Copy link
Collaborator

OK, the bug as is, is still valid in my opinion.

As a workaround, In that case, is much better to mark as binary (excludes from search and indexes) with the binary_file_patterns but still shows in sidebar.

However you will need a package https://github.com/titoBouzout/FindResultsApplyChanges that populates the exclusion list automatically when searching folders(but also avoids to populate exclusion for the right clicked folder/s), so someone asked for something very similar to what you want to do here, and here is the explanation with the use case https://github.com/titoBouzout/FindResultsApplyChanges/issues/12

@franciscolourenco
Copy link
Author

Thanks, didn't know that package. The only drawback of it is This package disables the "double-click = open file" in Find Results.

Now the workaround of adding each module individually works but is cumbersome. Currently using a symlink with other name so that sublime catches all the contents of the folder: src/my_modules -> src/node_modules. This works fine so far, but its non optimal because the way git handles symlinks.

@titoBouzout
Copy link
Collaborator

about double click

I found some sort of a solution to this issue. It appears that open-include package allows using Alt+D to jump to any line of search results. Which for me is even nicer alternative to double-click

about

Now the workaround of adding each module individually works but is cumbersome

That's not the idea, the idea is to completely skip node_modules using node_modules/** and then just right click the folder on sidebar when you need to search for something there. You can select many folder at the same time, and these folder will not be exclude because you explicitly are selecting these.

@franciscolourenco
Copy link
Author

ah, good point. my main use case is not with search though, but with goto everything. also the modules I'm referring to are just normal part of my code, except they are included using browserify.

@titoBouzout
Copy link
Collaborator

I see okei =) well..

workaround for the other issue.. about git, you may be able to symlink from outside of your project, and then just drag the folder (you will have at least two folders in the project)

@franciscolourenco
Copy link
Author

its more about when other people clone the project and so on, some extra steps necessary to setup the symlink, but thanks for the suggestion.

Just so its clear this issue is still open.

@maxgaurav
Copy link

maxgaurav commented Jul 21, 2016

You can exclude the folder using the folder_exclude_patterns in project settings

{
  "folders" : 
  [
    {
        "path" : "/path/to/your/project",
        "folder_exclude_patterns" : [ "project/node_modules" ]
    }
  ]
}

This will remove the node_modules folder from the root of your project but will not remove it from other nested directories

@franciscolourenco
Copy link
Author

franciscolourenco commented Jul 25, 2016

@maxgaurav thank you. The problem here is that for this to work, a different path needs to be defined for each project. This request is about a global configuration which you don't need to set for each project. Furthermore this configuration would break when the project is cloned to a different computer.

@powelski
Copy link

What is the status of this? I'm giving it +1. I want to exclude /vendor folder, but only the one at the root of my project. I think it would be nice if those exclude patterns were not just matched, but intepreted as either pattern or relative path (starting with slash).

Another solution would be to introduce some project path variable to be used inside the pattern, but I'm not too excited about that.

@demidovsky
Copy link

demidovsky commented Jul 30, 2018

Relative paths would be great, of course.
Until that, @maxgaurav's workaround can be written shorter:

  "folder_exclude_patterns":
  [
    ".git",
    ...
    "/absolute/path/to/your/project/node_modules"
  ]

@powelski
Copy link

It’s not a workaround, what if the folder is in the root?

@demidovsky
Copy link

demidovsky commented Jul 30, 2018

I mean, setting "folder_exclude_patterns": ["/Users/username/Projects/projectname/build"]
will exclude build in the root of project, but leave it in other directories, e.g: /Users/username/Projects/projectname/public/build

(corrected previous comment to indicate absolute url)

@powelski
Copy link

That’s what I’m doing now, but it has zero portability. Would be great if Sublime had used another syntax for excluding. Using it just as a needle is faulty idea imho.

@wbond
Copy link
Member

wbond commented Feb 14, 2020

As of build 4067, you can now use // to refer to a folder in a project. Thus the pattern //node_modules will match a root-level node_modules folder in any project folder you have.

@wbond wbond closed this as completed Feb 14, 2020
@wbond wbond added the R: fixed label Feb 14, 2020
@wbond wbond added this to the Build 4067 milestone Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants