Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Since I already define my "intermediary" files with set suffixes=.o,~,..., how can I reuse that to make NERDTree not show those files?

It seems anti-DRY to put them all again in a different variable.

share|improve this question

migrated from programmers.stackexchange.com May 10 '11 at 14:28

This question came from our site for professional programmers interested in conceptual questions about software development.

1 Answer 1

up vote 3 down vote accepted

You can copy your suffixes to the NERDTreeIgnore variable.

As suffixes holds plain strings that Vim matches at the end of file names and NERDTreeIgnore holds regular expressions matched against complete names, to match similar files you'd have to

  • anchor the suffixes strings to the end of names by appending $, and
  • escape all regex-specific characters.

For example:

let NERDTreeIgnore = []
for suffix in split(&suffixes, ',')
    let NERDTreeIgnore += [ escape(suffix, '.~') . '$' ]
endfor

Note: This only escapes . (dot) and ~ (tilde) as they seem to be the only relevant characters appearing in the default suffixes. Add more characters to escape()'s second argument if you use different suffixes or need a more general solution.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.