I am trying to set an option but it does not work when using a variable.
This is what actually works:
set runtimepath+=~/.vim/bundle/foo/foo.vim/
When I try this, it DOES NOT work anymore:
g:foo_path = '~/.vim/bundle/foo/foo.vim/'
set runtimepath+=g:foo_path
I have seen a similar topic here and they use the following command to set an option with a variable:
let &backupdir=s:vimetc.'backups/'
However, when I try this:
let &runtimepath+=g:foo_path
It still DOES NOT work. I am getting:
E734: Wrong variable type for +=
Any ideas? Thanks.
The problem is set
does not support using string variables and let
does not support += for string types.
This should work:
let g:foo_path = '~/.vim/bundle/foo/foo.vim/'
let &rtp.= ',' . g:foo_path
another workaround
exe 'set runtimpath='.a:lines
after reviewer's comment, a 2.0 version
exe 'set runtimepath='.&runtimepath.','.g:foo_path
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With