1. Searches a directory for all files that end in the string "Template"
2. Return those file names to the user as chooseable list, similar to
the way that the spell checker functionality works when you use the z=
command.
Well, as an ugly first-pass hack:
:let s = expand("*template")
:echo substitute("\n".s."\n",
'^\%([^[:cntrl:]]*[[:cntrl:]]\)\{'.(confirm('Which file?',
s)).'}\([^[:cntrl:]]*\).*', '\1', 'g')
Those two lines create a prompt with available matches for
whatever is stashed in "s".
Instead of an :echo you can do an assignment, or make it the
return value of a function so you don't have to recreate this
beast repeatedly.
It can be wrapped in a function if desired. Hari's suggestion
was a good one, but requires Vim7 (at least it didn't work on 6.3
when I tried it because of the need for the inputlist() and
split() functions). As you reference the "like spell-checker",
you're likely running 7.0 and thus are safe with his much clearer
method.
The above two-liner, despite its brutish opacity, should work at
least back to 6.0.
-tim