As title howto source all files under a folder recursively except files that end with .bak
2 Answers
Setting wildignore can have quite a few side effects (especially if done globally).
So I would do:
let s:prefix = '/path/to/folder'
let files = filter(glob(prefix . '/**/*.bak', 1, 1), "fnamemodify(v:val, ':e') != 'bak'")
for fname in files
execute 'source' fname
endfor
You can only 'source' a file at a time. Therefore, build the list of files first, and then source them one by one.
set wildignore=*.bak
let s:prefix = '/path/to/folder'
for s:fname in glob(s:prefix . '/**', 0, 1)
execute 'source' s:fname
endfor
However, normally you should only source *.vim files, so then it becomes
let s:prefix = '/path/to/folder'
for s:fname in glob(s:prefix . '/**/*.vim', 1, 1)
execute 'source' s:fname
endfor
But note that file system search does not guarantee order, so there can be some side-effects.
runtime
with a globruntime
what would glob would be to achieve the goal? @D.BenKnobleruntime dir/*.vim dir/**/*.vim
i think. (Though if you use dir=plugin, and you get that setup before vim loads plugins, it will happen automatically.)