Reputation: 12413
Sometimes I want to use a minimal vim configuration, so with pathogen I have the following alias:
alias v='vim -u "$HOME/.vim/simple.vim" --noplugins'
and in the simple.vim file I have the following lines:
let g:p0 = split(&runtimepath, ',')[0]
exec "source" . g:p0 . "/plugin/NERD_commenter.vim"
this fails when g:p0
contains spaces. I tried
exec "source" . "'" . g:p0 . "/plugin/NERD_commenter.vim" . "'"
and also
exec "source" . '"' . g:p0 . "/plugin/NERD_commenter.vim" . '"'
but they both fail. Any ideas on how to solve this?
Upvotes: 1
Views: 378
Reputation: 42677
You should use the fnameescape()
function
exec 'source ' . fnameescape(g:p0 . '/plugin/NERD_commenter.vim')
Of course, even better would be using the runtime
command
runtime plugin/NERD_commenter.vim
Upvotes: 3