문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top