Sublime Forum

How to exclude files from root folder only

#1

I am pretty new to sublime text. I don’t know if this question is asked already no this forum because I can’t find any. Sorry if this is a newbie question.

my project structure

project/
├── .workspaces
│   └── w1.sublime-workspace
├── .venv
          (lots of files)
├── Pipfile
└── project.sublime-project

I have a folder .venv/lib/python3.7/site-packages/ which contains all the dependencies. I want to show them on the side panel as a different folder lib
Screenshot%20from%202020-06-25%2002-01-56

but I can’t get rid of the files from the root of lib folder.

this is my config

		{
			"name": "lib",
			"path": ".venv/lib/python3.7/site-packages/",
			"folder_exclude_patterns": ["*.dist-info"],
			// "file_exclude_patterns": [""]
		}
0 Likes

#2

Maybe try

{
	"name": "lib",
	"path": ".venv/lib/python3.7/site-packages/",
	"folder_include_patterns": ["/*/"],
	"folder_exclude_patterns": ["*.dist-info"],
}

See also the patterns documentation.

0 Likes

#3
"folder_include_patterns": ["/*/"],

it removes all the folders … only the unwanted files are shown
edit:
Screenshot%20from%202020-06-25%2011-25-31

0 Likes

#4

Haha. Phooey. Maybe try a similar thing with file_*_patterns, then. The tricky bit is that ST thinks a * next to a / is a **-style glob. Maybe you can fool it with a ? instead. So maybe something like this?

"file_exclude_patterns": [
    "/?*",
    "*.dist-info",
],
0 Likes

#6

This also removes every file.

0 Likes

#7

In ST4, you will be able to anchor a pattern to the project root using a leading double-slash (//). In ST3 you can still use an absolute path, which won’t be portable but should help if you don’t plan on moving the project around. (docs)

# All versions
"file_exclude_patterns": ["/path/to/project/.venv/lib/python3.7/site-packages/*"]
# ST4 only
"file_exclude_patterns": ["//*"]
1 Like

#8

it doesn’t work

0 Likes

#9

I don’t understand why this works and does not hide all files in all folders. If the docs say this:

  • In a */ prefix or /* suffix, the * will match / characters

Then the trailing /* should match every single file, no?

1 Like

#10

whoops, that’s my fault, I again mixed that up :sweat_smile: … yes you’re right. it removes all files.
this happened because I added each of the required folders in folder_include_patterns and mistakenly thought it was caused by /* it is the second time this happened. sorry for that

0 Likes

#11

Again, you can try to trick it (and I have not tested this) by putting a ? before the * to un-trigger the /* special case.

0 Likes

#12

doesn’t work :frowning:

as a temporary fix, I have added scripts to automatically add folders to the project file whenever I install a new package

edit: also I think this is a better approach because I don’t want to work with all the packages, if I just need to use sk-learn I dont need to open scipy or Pillow or numpy

0 Likes