vim-template
vim-template copied to clipboard
Option to ask for user input for undefined variables?
Hi there! Thanks for the plugin!
There's a vscode plugin I use frequently called "File Templates", and it has a feature where you can provide the arguments for undefined template variables when creating a file. This is useful for me, because at work we have a header where we have to define the product/module the script belongs to, which isn't easily available through env vars or the filepath.
I'm thinking it might be easy enough to supply the vars as optional parameters to the :Template function. Sort of like:
:Template <pattern> <undefined_var_1=value> <undefined_var_2=value>
Perhaps the behavior is that if the variable is defined, these values will override the defaults there?
At the moment, I keep the variables un-expanded, and substitute them when I create the file.
I'm not so familiar with vimscript, so if there's an easy way for me to workaround this, I'm all ears :smile:
I came here for the exact same reason. It would be nice to have something like a %USERINPUT% variable that prompts for filling on template insertion.
I haven't looked into it -- don't have time to yet -- but I'll probably try scripting it with the template_user_variables command later.