I have a .zshrc and .vimrc file
In my .zshrc file I have syncfolder="$HOME/Google Drive/Dropbox"
I now want to reference syncfolder within my .vimrc file, is this possible (if so, how)?
Also, within my .vimrc file I'm sourcing lots of other files and I want to make that more efficient.
The following doesn't work:
let vimfolder="~/Google Drive/Dropbox/Fresh Install/Shell/vim"
source "$vimfolder/settings.vim"
source $vimfolder/vundle.vim
source $vimfolder/mapping.vim
source $vimfolder/filetypes.vim
source $vimfolder/commands.vim
...I've tried multiple variants where vimfolder included $HOME and in another I've tried exporting a variable from my .zshrc file, like so...
export SYNCFOLDER=$syncfolder
...in the hope that I could access it from within my .vimrc but it didn't work.
Any ideas?
You need to use :execute to evaluate a variable in most Ex commands. Vim variables do not have a $ prefix, those are environment variables (which you can reference from Vimscript, too):
execute 'source' vimfolder . '/settings.vim'
However, in this particular case, I'd rather add the location to 'runtimepath' and then use :runtime:
set runtimepath+=~/Google\ Drive/Dropbox/Fresh\ Install/Shell/vim
runtime settings.vim
Another alternative is symbolic links, so you don't have change anything in your Vim setup.
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