Hide files *only* from Project view
已回答
I love Python because of it's simplicity, but I hate the deicion to require __init__.py-files in every package folder. I always leave them empty, and it's annoying me that these empty files are stealing real-estate on my screen and making my project structures more cluttered when browsing for a file.
The only way I know to hide files is in the "File Types"-dialog, but this also hides them from the parser, so I get errors on all the libraries and modules that uses __init__.py-files. Is there a way to hide them only from the Project viewer?
请先登录再写评论。
Hello Preben,
Right now PyCharm doesn't support such exclusions.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Has this changed in more recent versions of PyCharm (like the 2.0 version)? I, too, would love to hide __init__.py files!
No. (And given that __init__.py files often contain code, we don't think it's a really good idea to hide them.)
You can add the Eclipse project files to Settings | File Types | Files and folders to ignore. (This wouldn't work for __init__, but for the Eclipse projects this won't cause any issues.)
That's now Settings | Editor > File Types > Ignore files and folders (for those coming here from google).
I agree that it's a bad idea to hide `__init__.py` files as they are essential in Python...
But, I would love it if PyCharm could highlight/indicate when a file is empty so that I know that I don't have to open it to check whether it contains code.
Ian, feel free to vote for https://youtrack.jetbrains.com/issue/PY-22648.
I know why PyCharm can't implement hide specify files feature. This will not only effect which files you see but also effect python packages while indexing project tree.
For example: Try add virtualenv (eg. .env directory). You will not get any suggestions from 3rd library that installed via pip.
Showing __init__.py files particularly when empty, is just annoying and it's only matched by the inability to arranging the files and directories in a custom order .
If you do not change the __init__.py s often enough to always have them on, then there really is not a good reason to show them. Though I agree they should not be hidden by default.
`__init__.py` files can be hidden from the project tree by creating a new local scope in preferences -> Scopes.
Just add the pattern: `!file:*/__init__.py` and Apply.
Then at the top of the project tree change the display to the new scope you just created.
Note, you'll need to toggle back to inspect these files or ensure you've selected the complete file scope for the project in find or other search modals.
https://intellij-support.jetbrains.com/hc/en-us/community/posts/205804719/comments/360003025640
jfoster - best answer, well done
Jrmanev. Thanks. Glad it helped. I still use this trick.
Scroll up 2 comments and you'll find the best answer ever