简体   繁体   中英

vimrc import file

I have a repository of my home config files - http://hg.jackleo.info/home-configs

I noticed that my vim configuration is getting bigger and bigger (90% of commits is only related to vim) so I want to trow it to separate repository.

The problem is that since i'm using home-config repository at my actual home folder vimrc file is also in same place. If I would include subrepo to Vim configuration (folder .vim) I couldn't commit .vimrc file to that sub-repository.

Is there a way to simply write import file_path_to_other_config and hold exact configuration in .vim folder?

You could use the source command in your vimrc:

source file_path_to_other_config

Here is the vim help page on source: http://vimdoc.sourceforge.net/htmldoc/repeat.html#:source

I had a similar thought some while ago and came up with quite a simple solution. I have a ~/.vim/Makefile which reads like this:

$(HOME)/.vimrc: Makefile vimrc.tmpl
    @cat vimrc.tmpl | sed 's\@@HOME@@\$(HOME)\g' > $(HOME)/.vimrc

With .vim/vimrc.tmpl being:

let $VIM = '@@HOME@@/.vim'

let $VIMRC = $VIM.'/custom.vimrc'

if filereadable($VIMRC)
  source $VIMRC
endif

I have everything in an extra git repository and when I work in a new system, I only have to clone the repository and call make inside ~/.vim .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM