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')
Thanks a *ton* Tim! This looks very succinct (if not a bit
frightening). I'll definitely try this one out too.
The 10k foot view is "offer the user the list of files (the
confirm() call) extract the Nth position from that list of files
as determined by the index returned from the confirm() call".
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.
Vim7 added lists (among other more advanced datatypes, IIRC)
which makes this hack considerably less taxing. The above hack
is a way of treating a string like a list, using the newline
characters (which happen to be control-characters, and thus match
the POSIX-type [[:cntrl:]] notation) as demarcations between list
items.
You could probably change the
"\n".s."\n"
to just
"\n".s
as, looking over it, it doesn't seem to require something
following the item of interest.
Hope this helps make a bit more sense of the chaos. :)
-tim