I am editing the file, for example,
/path/to/file.txt
using vim, hence the current directory is this
/path/to.
Now I have a directory
/other/path/to/vim/files
that contains sourceA.vim. In addition, there is a file sourceB.vimin
/other/path/to/vim/files/lib/sourceB.vim
In sourceA.vim, I want to specify sourceB.vim, so I put the file
so lib/sourceB.vim
in it.
Now, in the file.txt file, I do
:so /other/path/to/vim/files/sourceA.vim
that which does not work, since the search system is clearly not prepared for relative path names along with a source from another directory.
To fix this, I put
execute "so " . expand("<sfile>:p:h") . "/lib/sourceB.vim"
in sourceA.vim, which does what I want.
However, I find the solution a bit awkward and wondered if there is a more elegant solution for it.
I cannot put sourceA.vim or sourceB.vim in the vim folder plugin.
source
share