简体   繁体   English

vimrc导入文件

[英]vimrc import file

I have a repository of my home config files - http://hg.jackleo.info/home-configs 我有一个我的家庭配置文件的存储库 - 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. 我注意到我的vim配置越来越大(90%的提交只与vim有关)所以我想把它扔到单独的存储库中。

The problem is that since i'm using home-config repository at my actual home folder vimrc file is also in same place. 问题是,因为我在我的实际主文件夹vimrc文件中使用home-config存储库也在同一个地方。 If I would include subrepo to Vim configuration (folder .vim) I couldn't commit .vimrc file to that sub-repository. 如果我将subrepo包含到Vim配置(文件夹.vim),我无法将.vimrc文件提交到该子存储库。

Is there a way to simply write import file_path_to_other_config and hold exact configuration in .vim folder? 有没有办法简单地写入import file_path_to_other_config并在.vim文件夹中保存确切的配置?

You could use the source command in your vimrc: 您可以在vimrc中使用source命令:

source file_path_to_other_config

Here is the vim help page on source: http://vimdoc.sourceforge.net/htmldoc/repeat.html#:source 这是源上的vim帮助页面: 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: 我有一个~/.vim/Makefile ,其内容如下:

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

With .vim/vimrc.tmpl being: .vim/vimrc.tmpl是:

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 . 我有一个额外的git存储库,当我在一个新系统中工作时,我只需要克隆存储库并在~/.vim调用make

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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