I am editing a file like
/path/to/file.txt
with vim, hence the current directory is
/path/to
.
Now, I have a directory
/other/path/to/vim/files
that contains sourceA.vim
. Also, there is a sourceB.vim
file in
/other/path/to/vim/files/lib/sourceB.vim
In sourceA.vim
, I want to source sourceB.vim
, so I put a
so lib/sourceB.vim
into it.
Now, in my file.txt, I do a
:so /other/path/to/vim/files/sourceA.vim
which fails, because the sourcing system is obviously not prepared for relative path names along with sourcing from another directory.
In order to fix this, I put a
execute "so " . expand("<sfile>:p:h") . "/lib/sourceB.vim"
into sourceA.vim
which does what I want.
However, I find the solution a bit clumsy and was wondering if there is a more elegant solution to it.
I cannot put the sourceA.vim nor sourceB.vim into vim's plugin
folder.