Say that I have defined two files
and that I placed both of them in ~/.vim/ftplugin folder.
Now assume that in my .vimrc I have the following
" do something
command MyCommand :call MyFun(b:foo, b:bar)
When I open a Python or Cobol file everything works fine, but when I open any other file with different filetype and try to run
:MyCommand, then I get the E121: Undefined variable: b:foo for very good reasons.
A trivial solution would be to copy
command MyCommand :call MyFun(b:foo, b:bar) in both python.vim and cobol.vim and remove it from .vimrc but to be honest I really don't like that solution.
I am wondering if there a way to define some default values and if so how to deal with that, or, if you have any other more elegant solution, feel free to share.