如何在 Sublime Text 文件夹视图中显示二进制文件

How to show binary files in Sublime Text Folder View

我正在使用 Sublime Text 3 编写 C 库。我希望能够引用 lib 构建目录,并查看实际构建的二进制文件。但是,Sublime 将目录显示为空。

如何使库二进制文件在 Sublime Text 文件夹视图中可见?

ST3 的默认首选项包含:

// 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"],

如果您将其复制到您的用户首选项中,并将您想要在边栏中显示的文件类型从 file_exclude_patterns 移动到 binary_file_patterns,那么它们将在边栏中可见,但仍然忽略 Goto Anything。

侧边栏中显示和不显示的内容由以下两个设置以及要记住的一个附加设置控制(此处显示为默认值):

// 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"],

folder_exclude_patterns 会自动阻止文件夹列表出现在侧边栏中(这里是版本控制系统的控制目录),而 file_exclude_patterns 对文件执行相同操作并包括已编译的其他内容多个平台的目标文件和库文件。

为了让它们出现在边栏中,您需要修改 file_exclude_patterns 默认值,这样您要查看的文件就不会列出。

如果这样做,文件将显示在边栏中,但当您使用 Goto Anything 或在项目中搜索时,它们也会显示在要打开的文件列表中。 要解决这个问题,您需要将从 file_exclude_patterns 中删除的任何文件添加到 binary_file_patterns,以便 Sublime 知道它们是二进制的,因此没有意义。

要调整设置,请使用 Preferences > Settings,然后将左侧窗格中的默认设置复制到右侧的自定义设置,然后在右侧修改版本。

确保您不只是在不复制默认设置的情况下创建新设置,或者您实际上是在关闭所有默认排除项,这可能会导致后续问题。