1

How to filter out files by extension in NERDTree? shows filtering OUT files by extension, but I'd like to filter IN files by extension. Is there any way to show only specific extensions and folders in NERDTree?

Paul Kim
  • 1,153
  • 1
  • 9
  • 17

1 Answers1

2

This seems to work:

let NERDTreeIgnore=['\(.txt\|.md\)\@<!$[[file]]']

This will ignore all files that don't end in .txt OR (\|) .md.

It matches the atom .txt OR .md and then uses the \@<! operand (see :help \@<!) to match if the preceding atom does NOT match just before $ (the end of the line). The [[file]] at the end is NERDTree internals that specifies files instead of directories. If you don't use this directories that don't end in that file extension will be ignored too.

Conner
  • 30,144
  • 8
  • 52
  • 73
  • So for multiple extensions I just need to add multiple lines of the similar code, and directories that don't have those filetypes will be ignored in the tree? Thanks! – Paul Kim Nov 25 '18 at 17:45
  • You can use the `\|` operator within the selection atom as shown in the edit above. Please upvote or accept answer if it helps. – Conner Nov 26 '18 at 01:06