>> 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.

Thanks a *ton* Tim!  This looks very succinct (if not a bit
frightening).  I'll definitely try this one out too.

> 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.

Wow, I'm glad that I started Vim scripting after version 7 was released,
because it looks like it was much more difficult to script using version
6.

> The above two-liner, despite its brutish opacity, should work at
> least back to 6.0.

Thanks again!

Tom Purl

Reply via email to