简体   繁体   English

如何在NERDTree中按扩展名过滤掉文件?

[英]How to filter out files by extension in NERDTree?

I would like to *.pyc files not to be shown in NERDTree vim plugin. 我想*.pyc文件不能在NERDTree vim插件中显示。

How to achieve that? 怎么实现呢?

You want the NERDTreeIgnore option. 你想要NERDTreeIgnore选项。 For example, in your .vimrc : 例如,在.vimrc

let NERDTreeIgnore = ['\.pyc$']

Where NERDTreeIgnore is an array of regular expressions that match the files you want to exclude. 其中NERDTreeIgnore是一个与要排除的文件匹配的正则表达式数组。

Just ran into the problem: What about hiding binary files that do not have an extension? 刚遇到问题:如何隐藏没有扩展名的二进制文件?

Can't hide them, but can sort files to eliminate some cheesy clutter. 无法隐藏它们,但可以对文件进行排序以消除一些俗气的混乱。 Problem looks like: 问题看起来像:

file1*
file1.c
file2*
file2.c

Solution: 解:

let NERDTreeSortOrder=['\.c$']

Result: 结果:

file1.c
file2.c
file1*
file2*

which will sort first the files ending with ".c" (followed by some other extension if you want). 它将首先排序以“.c”结尾的文件(如果需要,则后跟一些其他扩展名)。 You don't get rid of the binary files, but it becomes manageable. 你没有摆脱二进制文件,但它变得易于管理。

NERDTree has a mechanism to detect and highlight files with the extra execute bit, where -rwxr-xr-x displays in bold with a "*" at the end of the filename. NERDTree有一种机制来检测和突出显示带有额外执行位的文件,其中-rwxr-xr-x以粗体显示,文件名末尾带有“*”。 It would not be hard to add an extra mechanism to hide executable files (useful for compiled stuff, not so desirable for scripts). 添加额外的机制来隐藏可执行文件并不困难(对于编译的东西很有用,对于脚本来说并不是那么理想)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM