I created a file named test.vim containing code below.
vim9script var a = 1 echo a export var b = 2 echo b I copy that file to these place:
~/Documents/test.vim~/.vim/test.vim~/.vim/pack/test.vim~/.vim/pack/testing/start/testing-vim/test.vim~/.vim/pack/testing/start/testing-vim/autoload/test.vim
I cd to each of above and open the test.vim file and source it, each gives the expected output:
1 2 But when I source it the second time, the file in the last directory gives this error:
line 5: E1041: Redefining script item: "b" Is this the intended behaviour? I find this trouble when writing and testing a plugin in that directory.
If this is actually the intended behaviour, is there a way to disable this?
I use version 9.1.1498.
export class Complexand this class is imported in calculator.vim. When I am not in that last path, I can easily test theComplexclass directly inside complex-number.vim when adding a feature (usingecho, for example), since I can source it multiple times. (Or is this actually the bug?) But when it is already in the vim pack path, since I cannot source the file multiple times, to test it I have to use the whole plugin by opening and closing another vim session.autoloaddo not prevent that the corresponding file is "reloaded" (i.e.so %) to recompile it and get the new version. But the exportation of a variable inautoloaddo prevent that the corresponding file is "reloaded" (i.e.so %) to recompile it and get the new version of the variable.autoloaddir and openAstPrinter.vim. Near bottom of the file I have a commented test that I use when I implement that. Uncomment that. Source this file once. Modify the test. Source again. It works. Now clone again to vim pack path. And do the same. It doesn't work. By using the accepted answer with my binding (see also my answer) it now works. This might be not the common workflow. But I think it is really useful.