I have a plugin that sets a global variable and checks it each time the plugin is loaded to avoid loading itself multiple times. I would like to allow reloading of the plugin (allow reloading of the plugin) without altering the plugin itself. The plugin simply checks to see that it's variable exists (i.e. exists('g:var_name')
)—is there a way to unset said variable so that the exists()
check returns false?
p.s. I don't want to alter the plugin itself because I use pathogen with git submodules pointed at the plugin's repo.
I found the Vim documentation for vimscript, which has a section on variables:
To delete a variable use the ":unlet" command. Example:
:unlet s:count
You should be able to :unlet g:var_name
.
The problem with this is that if the functions defined in the plugin are not defined with function!
then you're going to get lots of errors when the plugin is sourced for a second time. The plugin may also be doing initial setup that could get fouled up by running it twice.
In general, if the plugin author has added a loaded trap it's probably there for a reason.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With