Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I exclude a folder from search in sublime text 3 permanently?

is there a way to always ignore a folder... in project view.

I have multiple apps in one repo and have 'node_modules' in each app

mainapp ├── microapp │   └── node_modules ├── microapp2 │   └── node_modules ├── index ├── config └── assets 

I want to exclude from search the node_modules folder when i search inside project in the above structure.

like image 302
nolawi Avatar asked Jul 31 '17 19:07

nolawi


People also ask

How do I exclude files from a folder?

(2) Go to the "Settings" tab and Click "Exclude files and locations". Then, click "Browse". (3) Here, at this step, you can use either a file or a folder. Select a file or a folder and click OK.

How do I delete a folder in Sublime Text?

Right click on the folder and then select "Remove folder from project".

What is exclude file?

If the project is a Web Site, Visual Studio excludes a file from the project by adding an extension ". exclude" to mark it as excluded. So all files will the extension ". exclude" will not be used in the project. ".


2 Answers

Go to the Settings menu and in the Preferences.sublime-settings file for the user and add a new node to the json named folder_exclude_patterns. In it, add the folders that you don't want to be displayed (in json array format).

Example:

{     // ... other settings     "folder_exclude_patterns": ["node_modules", "another_folder"], } 

If you want to exclude certain directory or file without hiding it from the sidebar, you can ignore the above solution and Add Exclude Filter in the Where section of the search bar. But you will have to specify it everytime you change the search directory.

Note: You might need to restart Sublime Text in order to see the changes, as mentioned by @Soferio

like image 88
SUB0DH Avatar answered Sep 23 '22 17:09

SUB0DH


If you go to the Preferences menu and then select Settings, it will open a JSON file of all the settings and their default values. This file also serves as documentation for what the settings mean. Two of them are relevant here. Here's the snippet from the Settings JSON file (last verified in Sublime Text 4):

// folder_exclude_patterns and file_exclude_patterns control which files // are listed in folders on the side bar. These can also be set on a per- // project basis. "folder_exclude_patterns": [".svn", ".git", ".hg", "CVS", ".Trash", ".Trash-*"], "file_exclude_patterns": ["*.pyc", "*.pyo", "*.exe", "*.dll", "*.obj","*.o", "*.a", "*.lib", "*.so", "*.dylib", "*.ncb", "*.sdf", "*.suo", "*.pdb", "*.idb", ".DS_Store", ".directory", "desktop.ini", "*.class", "*.psd", "*.db", "*.sublime-workspace"], // These files will still show up in the side bar, but won't be included in // Goto Anything or Find in Files "binary_file_patterns": ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds", "*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip"], 

It says here that "folder_exclude_patterns" hides it from the side bar, while "binary_file_patterns" hides it from search (these "won't be included in Goto Anything or Find in Files"). So if you want to exclude it from both, you can open the User Settings file, which overrides the default settings, and add the following.

Note that the User Settings file is what you see and can edit in the right-hand pane when you go to Preferences --> Settings.

Anyway, add the following:

{     "folder_exclude_patterns": ["node_modules"],     "binary_file_patterns": ["*/node_modules/*"] } 

The two entries above are different because the former is a folder pattern while the latter is a file pattern.

like image 37
Alex Altair Avatar answered Sep 22 '22 17:09

Alex Altair