I have this in $HOME/.vimrc
:
if filereadable(".vim.custom")
so .vim.custom
endif
This allows me to put a .vim.custom
file in every directory to load commands and options specific to that directory. If you’re working on multiple projects that have deep directory structures you might need something more sophisticated (e.g. walk up the directory tree until a .vim.custom
is found), but the same basic idea will work.
UPDATE:
I now do something like this in order to read a .vim
file from the same directory as the file I’m editing, regardless of what the current directory is.
let b:thisdir=expand("%:p:h")
let b:vim=b:thisdir."/.vim"
if (filereadable(b:vim))
execute "source ".b:vim
endif