Sublime Forum

Prevent preview of binary files

#1

Is there a way to prevent preview of binary files? For example, if I click on an image in the sidebar, the hex shows up in the text panel. I’d rather not see that. I don’t normally click on images in my text editor, but it does happen occasionally. It is also a problem when using Go To File and mistyping a file name. This actually happened to me this morning. I was looking to open a particular file, mistyped the name, and suddenly saw a blue progress bar working its way across the text area. It turns out that the Go To File had landed on a flash video about 30 Mb. I just don’t need that to happen.

… checking preferences …]

I found folder and file exclude patterns in global settings, but I’d kind of like to leave the references to the files in the sidebar. I also saw binary file pattern to keep binary files out of Go To *, which will solve the problem I encountered this morning. So it comes down to being able to leave binary files in the sidebar but not showing a preview of them if clicked. Possible?

0 Likes

#2

It’s not possible, but I don’t see why you’d need a 30mb flash video in your ST project. You can look into the following settings (found in your “default global settings” but you’ll want to add them to your user settings to preserve them from updates):

[code]folder_exclude_patterns

file_exclude_patterns

binary_file_patterns[/code]

Adjust these settings to remove images and videos from showing up in the Goto panel or the sidebar.

0 Likes

#3

I generally have all the files for same project in project folder. There is binary files there.

I agree there should be a built-in way to disable preview. As I say previously, is not the preview feature that is bad. The real problem is that steal focus of focused tab which is very distracting.

There is also situations on which you want to just do some quickly file operations such copy, duplicate or paste for binary files, and the editor hangs when you just click that files.

I wrote some useful feedback about this behaviour which was ignored viewtopic.php?f=2&t=3477#p16431

Regards,

0 Likes

#4

[quote]folder_exclude_patterns

file_exclude_patterns

binary_file_patterns[/quote]

These settings don’t help because remove the files from the sidebar. I prefer to see if there is some real file there, before deleting a folder, etc.
There is also a plguin I wrote “NoPreview” which is not perfect but good enough to at last workaround this .

0 Likes

#5

I don’t use projects. I just open folders. I prefer to see everything that’s there. Suppose I’m making an image tag in a web app and I can’t quite remember the name of the file, I can go over to the sidebar and scroll down a little bit and see it. Otherwise, I have to leave the ST2, go to Finder or Path Finder or Terminal and do it. It’s less intrusive/distracting to be able to stay in ST2. Before I started using ST2, I used TextMate and I had to filter out a lot of files for performance reasons. But ST2 is so incredibly fast, I don’t want to filter them out unless I have to.

[quote=“C0D312”]You can look into the following settings (found in your “default global settings” but you’ll want to add them to your user settings to preserve them from updates):

[code]folder_exclude_patterns

file_exclude_patterns

binary_file_patterns[/code]

Adjust these settings to remove images and videos from showing up in the Goto panel or the sidebar.[/quote]

I guess you didn’t get that in my original post…I should have looked before posting, but I looked while posting and saw those options. I added *.flv to binary_file_patterns so now I don’t have to worry about Go To hitting it. The rest will just depend on me not clicking on binary files. And that’s totally reasonable. I’m not complaining that ST2 can’t do it, just wondering if it can.

Peace.

0 Likes

#6

Whoops. Guess I missed that. That’s my bad, sorry.

That makes sense. I can see a use for having them in the sidebar.

The fact that when you click on an image or a video, Sublime hijacks the current buffer with the preview becomes very intrusive. So, I definitely agree that this could be improved.

As for inserting an image tag or similar into Sublime Text, once I get some free time (I have exams this week, ugh) I’m going to make a plugin that will autocomplete filenames that are in your sidebar. Should make things like a and img tags a lot easier.

0 Likes