I'm using Sublime Text 3 to write C libraries. I want to be able to reference the lib build directory, and see that a binary actually got built. However, Sublime shows the directory as empty.
How can I make the library binaries visible in Sublime Text Folders view?
What is and is not displayed in the side bar is controlled by the following two settings along with one additional setting to keep in mind (shown here with their default values):
// 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"],
"file_exclude_patterns": ["*.pyc", "*.pyo", "*.exe", "*.dll", "*.obj","*.o", "*.a", "*.lib", "*.so", "*.dylib", "*.ncb", "*.sdf", "*.suo", "*.pdb", "*.idb", ".DS_Store", "*.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"],
The folder_exclude_patterns automatically blocks a list of folders from appearing in the side bar (here the control directories for version controls systems) while file_exclude_patterns does the same for files and includes among other things compiled object files and library files for several platforms.
In order to have them appear in the side bar, you need to modify the file_exclude_patterns default so that the files you want to see aren't listed.
If you do that, the files will show up in the side bar, but they'll also show up in the list of files to open when you use Goto Anything or when you search in your project.
To fix that, you need to add any files that you remove from file_exclude_patterns to binary_file_patterns so that Sublime knows that they're binary and thus not interesting.
To tweak the settings, use Preferences > Settings, then copy the defaults from the left pane to your custom settings on the right, and modify the versions on the right.
Make sure you don't just create new settings without copying the defaults, or you're effectively turning off all of the default excludes, which will probably cause you issues down the line.
The Default preferences for ST3 contain:
// 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"],
"file_exclude_patterns": ["*.pyc", "*.pyo", "*.exe", "*.dll", "*.obj","*.o", "*.a", "*.lib", "*.so", "*.dylib", "*.ncb", "*.sdf", "*.suo", "*.pdb", "*.idb", ".DS_Store", "*.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"],
if you copy this into your user preferences, and move the file types you want to show in the sidebar from file_exclude_patterns to binary_file_patterns, then they will be visible in the sidebar, but still ignored for Goto Anything.
Related
I have a directory named project, and I navigated to Project > Add Folder to Project... in order to see the directory tree in my left sidebar. I noticed that doing this creates a file called index.sublime-project with the following content:
{
"folders":
[
{
"path": "."
}
]
}
I also noticed that there is another file in my directory called index.sublime-workspace, although this one does not appear in the tree view on the left sidebar of Sublime. It is only visible through windows explorer when I navigated to the Project directory.
What is the purpose of these files? Can I prevent them from being created every time I add folder to project?
Adding directories to the window using Project > Add Folder to Project is indeed one of the ways to open a folder (the others being to drag and drop a folder onto the window and File > Open Folder).
However, doing so do not create those files. To create them, you would need to use the Project > Save Project menu item. So you may have accidentally done that without realizing it. In theory a plugin could also create those files for you, though that seems unlikely (anything is possible though).
In any case, assuming you don't want them it's entirely safe to remove them.
A sublime-project file is a file that allows you to open folders in the side bar and then do things like apply settings that apply only to files in that window, alter what files and folders appear, and so on.
A sublime-workspace file is a localized session information for a particular window. Usually, they associated with a sublime-project file but they don't have to be. They store the state of the window, open files, etc so that you can close a window and then recall it later with the same state.
I've tried this but it doesn't seem to work:
{
// index_exclude_patterns indicate which files won't be indexed.
"index_exclude_patterns": ["tmp/*", "*.cache", "*.log"],
}
Perhaps I need to reindex? But I don't know how to do that...
Your issue is that the index is used to collect symbols for Goto Definition and has no effect on the list of files that are presented to you when you use Goto Anything. So adding those folders to the list of files to exclude in indexing doesn't stop you from seeing them in the file list.
Goto Anything offers you all of the files that are currently contained in your project (if you're using one) or all open folders, excluding any files that it considers to be binary, so in order to stop files from appearing in the Goto Anything panel you need to either have them removed from the project or considered to be binary.
The folder_exclude_patterns and file_exclude_patterns settings allow you to indicate what folder and file patterns respectively should not be considered part of the project. Extending those settings would remove the files from the sidebar and thus from Goto Anything.
If you want to be able to still see the files in the sidebar but not be offered the ability to jump to them with Goto Anything, you can modify the binary_file_patterns setting. That tells Sublime what files are considered to be binary, which will stop it from showing them in the Goto Anything panel or searching them via Find in Files but will still show them in the sidebar for you to manually open.
folder_exclude_patterns and file_exclude_patterns can be used in your sublime-project file (if you're using one) so that they can be set on a project by project basis. binary_file_patterns only works as a global setting, however.
Either way, you probably want to base your custom settings on the defaults or you may accidentally have files appear in your project that are currently being hidden.
I'm using sublime text 3 and I want to exclude files/directories but not in my sidebar.
For example...
I have those files:
/doc/blabla/event.rb with the text some content in it.
/app/event.rb with the text other content in it.
So, with Ctrl + P (find files) and writing "event" I want to see only /app/event.rb.
and, with Ctrl + Shift + F (find in all files) and writing "content" I want to see results, again, only for /app/event.rb
I configure sublime with this values into my Preferences.sublime-settings:
"folder_exclude_patterns": ["doc"],
this works beautifully but, it hides doc directory from sidebar too. I don't want this behavior. I only want to hide files from my search
For me, using Sublime 3 build 3083 binary_file_patterns was not working while I had the setting in the project.sublime-project file. Once I moved it to my Preferences.sublime-settings and added an '*' to the search it started excluding the folder from search results while leaving it in the sidebar. My Preferences.sublime-settings looks like so:
"binary_file_patterns":
[
"public/bower_components/*",
"public/javascripts/vendor/*",
"public-built/*"
],
and it works beautifully for me in sublime 3.
Also talked about in this post:
http://blog.lysender.com/2014/08/sublime-text-exclude-files-or-directories-from-go-to-anything-feature/
You aren't looking for folder_exclude_patterns, rather binary_file_patterns. Check the default settings for the current values in case you woul dlike to keep the default values. I don't know if it works on folders, so you'll have to try it out.
I have stumbled upon the same problem. Recently I've been trowing every project that I'm not currently working to a .old folder and it became really annoying as the suggestions of Sublime are ordered it always in first place, so I did the same as #Typenine suggested and put it in binary_file_patterns. It is working great:
"binary_file_patterns": ["*/.old/*", "*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds", "*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip"]
I recently upgraded to Textmate 2 and now my dotfiles are not showing up in the file browser. Obviously, this is important when working with stuff like .htaccess files.
Is there a way to enable this feature?
Quick solution
Move the focus to the file browser (⌥⌘⇥) and show invisibles (⌥⌘i)(key names: option/alt+command/windows+i/eye). All invisible files will appear in the file browser. Press ⌥⌘i again to hide them.
Permanent solution
If you want to always show some dotfiles (for instance .htaccess), you can either add them in Preferences > Projects > Include files matching…
or add the list of files you want to show to the include array in one of:
~/Library/Application Support/TextMate/Global.tmProperties (same as using Preferences)
~/.tm_properties (global)
.tm_properties (inside a specific directory/project)
You can add all dotfiles (.*) but I don't recommend it since it can be a lot of clutter.
That said, you can also exclude files with the exclude array.
You can modify the behavior of the file browser via the config file ~/.tm_properties
To list all dotfiles and directories, you can set:
include = "{$include,.*}"
If you want to exclude some of those, for example the .git directory, modify the exclude variable:
exclude = "{$exclude,.git}"
There are many more options, check the Textmate site as an entry point for whats possible: http://blog.macromates.com/2011/git-style-configuration/
You can do this in the preferences of Textmate 2.
Navigate to: Textmate -> Preferences -> Projects. You should see two fields, one for including files, and one for excluding. I replaced the value of "Include files matching" with {*,.*} so it includes all normal and hidden files. I then just add the hidden files I want to exclude to the "Exclude files matching" field, such as .git and .DS_Store.
I am new to SublimeText, use SublimeText3.
Along with the daily usage, I'm developing some plug-in, so I'd like to understand the manner deeply.
What I found strange is opening Preferences > Settings - Default,
a file Preferences.sublime-settings located at Library/Application Support/Sublime Text 3/Packages/Default.
However, there is actually no such a directory, so I assume this is a binary hardcoded Virtual directory/File.
Also, I noticed, there is a (non virtual) User directory and Preferences.sublime-settings where we can edit.
I think this is a very smart method to let the user preserve the default setting and override the configuration.
So far I just guessed like this, and I'd like to confirm my understandings here.
When a plugin is developed, the default setting is placed in the plugin folder, and a user-setting file is automatically created in the User folder. Am I correct?
Packages are run directly from the *.sublime-package files, located in the executable path I believe. These are simply renamed zips. You can override files by creating the proper folder and file name in the packages folder. Settings are loaded in the following order. First the Default package, then any plugins installed (in alphabetical order), finally the User directory. So anything specified in the Userdirectory will override/merge with anything preceding it.
With that out of the way, yes you should map the default settings to your plugins directory and the user ones to the user directory. The user setting file is not automatically created. For example, the following is an entry from Main.sublime-menu
{
"command": "open_file", "args":
{
"file": "${packages}/User/Preferences.sublime-settings",
"contents": "// Settings in here override those in \"Default/Preferences.sublime-settings\",\n// and are overridden in turn by file type specific settings.\n{\n\t$0\n}\n"
},
"caption": "Settings – User"
}
So when you first select the menu, it will try to create the file. If it doesn't exist, it should fill it with specified content.