I'm trying to dynamically create functions and commands that point to those functions. e.g. I have a directory:
modules/abc
modules/xyz
I want commands Abc and Xyz that point to functions Abc() and Xyz(). It appears I'm able to generate the function names dynamically, but I'm unable to create the command names dynamically. With the following, I get an error: E182 Invalid command name
let s:modules = split(glob("modules/*"))
for s:module in s:modules
let s:module_name = split(s:module, "/")[-1]
let s:prefix = toupper(s:module_name[0]) . s:module_name[1:]
function! {s:prefix}()
echo "inside " . s:prefix
endfunction
command! {s:prefix} call {s:prefix}()
endfor
I've tried with no luck:
command! s:prefix call {s:prefix}()
command! prefix call {s:prefix}()
What am I missing? Does anyone know how to do this in vimscript if it's possible?
Thanks,
Jim
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment